Skip to content

Commit e4f7bb3

Browse files
committed
fix: itemProp disqualifies link/script from Float hoisting; preconnect distinguishes omitted vs empty crossOrigin
Bug 1: headResourceKind now rejects itemProp/itemprop for stylesheet link and async script resources (matching the existing style resource check), preventing microdata-owned elements from being hoisted to document.head. Bug 2: Preconnect deduplication key no longer collapses undefined crossOrigin (no CORS) with empty-string crossOrigin (anonymous CORS) — String(undefined) produces 'undefined' while String('') produces '', giving distinct keys.
1 parent 6e5059b commit e4f7bb3

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

‎packages/octane/src/compiler/compile.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18371,8 +18371,10 @@ function headResourceKind(n) {
1837118371
if (attr.type !== 'Attribute' && attr.type !== 'JSXAttribute') continue;
1837218372
const name = jsxAttrRawName(attr);
1837318373
// Handlers keep the element per-site (matching React: a load/error
18374-
// listener needs an owned instance); markup injection disqualifies too.
18374+
// listener needs an owned instance); markup injection and microdata
18375+
// ownership (itemProp) disqualify too.
1837518376
if (name === 'onLoad' || name === 'onError' || name === 'dangerouslySetInnerHTML') return null;
18377+
if (name === 'itemProp' || name === 'itemprop') return null;
1837618378
if (name === 'precedence') hasPrecedence = true;
1837718379
else if (name === 'href') hasHref = true;
1837818380
else if (name === 'async') {

‎packages/octane/src/runtime.server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8168,7 +8168,7 @@ export function preinit(href: string, options: { as: string } & Record<string, u
81688168
export function preconnect(href: string, options?: { crossOrigin?: string }): void {
81698169
const value = coerceHintHref(href);
81708170
if (value === null) return;
8171-
const key = 'preconnect:' + String((options as any)?.crossOrigin ?? '') + ':' + value;
8171+
const key = 'preconnect:' + String((options as any)?.crossOrigin) + ':' + value;
81728172
const safeHref = sanitizeURL(value);
81738173
emitHeadHint(
81748174
key,

‎packages/octane/src/runtime.ts‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27808,16 +27808,13 @@ export function preconnect(href: string, options?: { crossOrigin?: string }): vo
2780827808
const rawHref = guardHintHref('preconnect', href);
2780927809
if (rawHref === null) return;
2781027810
const safeHref = sanitizeURL(rawHref);
27811-
insertHeadHint(
27812-
'preconnect:' + String((options as any)?.crossOrigin ?? '') + ':' + rawHref,
27813-
() => {
27814-
const l = document.createElement('link');
27815-
l.rel = 'preconnect';
27816-
l.href = safeHref;
27817-
applyHintAttrs(l, options);
27818-
return l;
27819-
},
27820-
);
27811+
insertHeadHint('preconnect:' + String((options as any)?.crossOrigin) + ':' + rawHref, () => {
27812+
const l = document.createElement('link');
27813+
l.rel = 'preconnect';
27814+
l.href = safeHref;
27815+
applyHintAttrs(l, options);
27816+
return l;
27817+
});
2782127818
}
2782227819

2782327820
/** React DOM `prefetchDNS(href)` — `<link rel="dns-prefetch">`. */

0 commit comments

Comments
 (0)