fix(jsx): align link hoisting and dedupe with React 19#4792
Merged
Conversation
Member
Author
|
@yusukebe |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Member
Author
|
Oops |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Member
Author
|
@yusukebe |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4792 +/- ##
==========================================
+ Coverage 91.47% 91.58% +0.10%
==========================================
Files 177 177
Lines 11578 11799 +221
Branches 3368 3458 +90
==========================================
+ Hits 10591 10806 +215
- Misses 986 992 +6
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
yusukebe
reviewed
Mar 6, 2026
src/jsx/intrinsic-element/common.ts
Outdated
| export const isStylesheetLinkWithPrecedence = (props: Props): boolean => | ||
| props.rel === 'stylesheet' && 'precedence' in props | ||
|
|
||
| export const shouldDeDupeByKey = (tagName: string, props: Props, supportSort: boolean): boolean => { |
Member
There was a problem hiding this comment.
Can you apply the flowing patch to remove the lint error though CI does not fail?
diff --git a/src/jsx/intrinsic-element/common.ts b/src/jsx/intrinsic-element/common.ts
index aaa2ce0c..937c0974 100644
--- a/src/jsx/intrinsic-element/common.ts
+++ b/src/jsx/intrinsic-element/common.ts
@@ -15,7 +15,11 @@ export const dataPrecedenceAttr = 'data-precedence'
export const isStylesheetLinkWithPrecedence = (props: Props): boolean =>
props.rel === 'stylesheet' && 'precedence' in props
-export const shouldDeDupeByKey = (tagName: string, props: Props, supportSort: boolean): boolean => {
+export const shouldDeDupeByKey = (
+ tagName: string,
+ _props: Props,
+ supportSort: boolean
+): boolean => {
if (tagName === 'link') {
return supportSort
}Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
Bundle size check
Compiler Diagnostics (tsc)
Compiler Diagnostics (typescript-go)
Reported by octocov |
HTTP Performance Benchmark
|
Member
Author
Member
|
Thank you! Looks good. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #4789
Summary
Because React 19 appears to dedupe only link elements that are stylesheet + precedence, this PR aligns Hono JSX runtime link hoisting/dedupe behavior with that model.
It fixes over-deduplication by href (for canonical / alternate / preload / icon / preconnect, etc.) and narrows dedupe to stylesheet links with precedence only.
As shown below, the list of links with issues reported in the issue will also remain without being deduplicated.
https://github.com/honojs/hono/compare/fix-hoisting-link-element-3?expand=1#diff-7077a729697655835dd10a0638c9e8ffaad5aef95597d9f409cc4e3f3fb9f848R374-R384
Compatibility
linkhoisting/dedupe behavior and tests.The author should do the following, if applicable
bun run format:fix && bun run lint:fixto format the code