Skip to content

feat: close the React Float behavioral gaps (#711) - #720

Merged
trueadm merged 5 commits into
mainfrom
feat/react19-float-gaps
Aug 12, 2026
Merged

trueadm merged 5 commits into
mainfrom
feat/react19-float-gaps

Conversation

@trueadm

@trueadm trueadm commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes the "Float behavioral gaps" section of #711 (the seven items from the verified 19.2.7 comparison in the comment feedback).

  1. Hoist exclusions — itemProp-bearing <meta>/<link> stay with their itemScope host, and metadata/Float resources that are direct children of <noscript> stay in the fallback content, symmetrically on client and server (hydration adopts the identical shape). One documented bound: the <noscript> exclusion is one nesting level deep — metadata wrapped in a further host inside <noscript> still hoists (noted in differences-from-react.md; deeper threading needs the noscript context to survive element recursion, a follow-up if real code hits it).
  2. Font preloads force anonymous CORS — crossorigin="" regardless of the caller's value, client + SSR.
  3. Preload → preinit option transfer — connection/integrity options seeded by a preload carry onto the initialized script/stylesheet (preinit's own values win); the server additionally coalesces the redundant preload out of the head fold (hint emission moved from string-append to a keyed, deletable map on HeadBuffer, participating in both suspense-replay snapshot/rewind sites).
  4. Module-script shared identity — one executable per src across preinitModule and <script async type="module" src>: the client seed scan now recognizes both marker forms, both insert paths register/consult one set, and the SSR pass cross-guards the two key namespaces. Both cross pairings (SSR preinitModule × client Float discovery; SSR Float × client preinitModule) adopt instead of duplicating.
  5. Preconnect identity includes the CORS mode — (url, crossOrigin) keys, client + SSR.
  6. Responsive image preloads omit the fallback href when imageSrcSet is present, client + SSR.
  7. Validation/filtering — unknown option keys are dropped (allowlist per React's recognized set); non-string/empty hrefs dev-warn and no-op across all hint entry points including the module variants.

Ledger + docs

Four cases flipped to covered with executed evidence (…18285c itemProp, …3bd259 noscript, …dc93d1 font CORS, …b15c17 connection-prop seeding); coverage report regenerated; differences-from-react.md updated (exclusions, unified hint semantics, and the now-obsolete "unknown keys pass through" sentence corrected). Changeset included.

Validation

  • pnpm format:check, pnpm typecheck

  • pnpm test (full suite) and node scripts/react-parity/check.mjs (full — executes the four new evidence records)

  • targeted: hoist-exclusions (12), resource-hints (42), float-resources (28), plus head-hydrate/nested-head neighbors — all green in dev and prod compile projects.

  • Every family was red-first: the exclusion suite failed with metadata hoisted to head; the hint cases failed 12/12 (font CORS, transfer, preconnect keys, image href, validation); the module-identity cases failed with duplicate scripts in both pairings. Two pre-existing contracts migrated deliberately: the legacy font-preload assertion now pins the React-correct crossorigin="", and untrusted-url's coercion probes flipped meaning — non-string hrefs never coerce now (dev-warn + no-op, calls() === 0), which retires the mutating-toString TOCTOU channel outright, and the unknown src option no longer serializes at all (the sanitize-through-option concern is moot when the key drops). The full suite caught that preconnect/prefetchDNS still coerced on the client — all six hint entry points now share the same strict guard.

  • Review-fix commit b76fb14 (both Bugbot findings, red-first): itemProp now disqualifies the Float RESOURCE forms too (the link/script classifier loop had missed the check the style/hoistable paths had), and the preconnect key distinguishes an omitted crossOrigin from '' — four distinct connection-mode identities, pinned by test. Full suite re-run: 18,669/18,669 clean.

Risk / follow-ups

  • The <noscript> depth bound above.
  • SSR-crossing preload→preinit transfer (preload rendered by the server, preinit called on the client) is not seeded from the DOM — in-memory transfer only; noted as residual.
  • After merge: tick the seven Float-gap checkboxes in React 19 parity: outstanding gaps and follow-ups after #709 #711.

Provenance

  • An agent produced this diff (agent-authored)

Note

Medium Risk
Touches SSR head buffering (including suspense snapshot/rewind), hydration shape for metadata, and resource-hint identity/deduping. Mistakes here can cause hydration mismatches or duplicate scripts, though the changes are covered by new conformance tests.

Overview
Closes remaining React Float behavioral gaps so document-metadata hoisting and resource hints match React on both client and server.

Hoist exclusions: itemProp-bearing <meta>/<link> (and Float resource forms) stay with their itemScope host, and metadata/resources that are direct children of <noscript> stay in fallback content. Compiler normalizeChildren / hoist classifiers enforce this so hydration adopts the same shape.

Resource-hint semantics: font preloads always emit anonymous CORS; preload connection/integrity options transfer onto the matching preinit (server coalesces the redundant preload via a keyed hintHtml map); preconnect identity includes CORS mode; responsive image preloads omit the fallback href; unknown option keys drop; non-string hrefs warn and no-op.

Module identity: one executable per src across preinitModule and <script async type="module" src> in SSR and on the hydrating client, so cross pairings no longer duplicate scripts.

Four ledger cases move to covered; docs and tests updated accordingly.

Reviewed by Cursor Bugbot for commit 1e25471. Bugbot is set up for automated code reviews on this repo. Configure here.

Hoist exclusions (itemProp metadata stays with its itemScope host;
noscript children stay in fallback content) on client and server; font
preloads force anonymous CORS; preload-seeded options transfer onto the
initialized resource with server-side preload coalescing (hint emission
moved to a keyed map on HeadBuffer, snapshot/rewind covered); preconnect
identity includes the CORS mode; responsive image preloads omit the
fallback href; unknown hint options drop and non-string hrefs dev-warn
and no-op across all six entry points; one executable identity per
module src across preinitModule and Float scripts on server and client.
Closes the Float behavioral gaps section of #711.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability labels Aug 12, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Autofix Details

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: itemProp still hoists Float resources
    • Added itemProp/itemprop early-return to the link/script attribute walk in headResourceKind, matching the existing style resource exclusion so microdata-owned stylesheets and async scripts no longer classify as Float resources.
  • ✅ Fixed: Preconnect CORS key collision
    • Removed the nullish coalescing to '' so String(undefined) produces 'undefined' while String('') produces '', giving distinct deduplication keys for omitted vs empty-string crossOrigin.

Create PR

Or push these changes by commenting:

@cursor push e4f7bb3ba4
Preview (e4f7bb3ba4)
diff --git a/packages/octane/src/compiler/compile.js b/packages/octane/src/compiler/compile.js
--- a/packages/octane/src/compiler/compile.js
+++ b/packages/octane/src/compiler/compile.js
@@ -18371,8 +18371,10 @@
 		if (attr.type !== 'Attribute' && attr.type !== 'JSXAttribute') continue;
 		const name = jsxAttrRawName(attr);
 		// Handlers keep the element per-site (matching React: a load/error
-		// listener needs an owned instance); markup injection disqualifies too.
+		// listener needs an owned instance); markup injection and microdata
+		// ownership (itemProp) disqualify too.
 		if (name === 'onLoad' || name === 'onError' || name === 'dangerouslySetInnerHTML') return null;
+		if (name === 'itemProp' || name === 'itemprop') return null;
 		if (name === 'precedence') hasPrecedence = true;
 		else if (name === 'href') hasHref = true;
 		else if (name === 'async') {

diff --git a/packages/octane/src/runtime.server.ts b/packages/octane/src/runtime.server.ts
--- a/packages/octane/src/runtime.server.ts
+++ b/packages/octane/src/runtime.server.ts
@@ -8168,7 +8168,7 @@
 export function preconnect(href: string, options?: { crossOrigin?: string }): void {
 	const value = coerceHintHref(href);
 	if (value === null) return;
-	const key = 'preconnect:' + String((options as any)?.crossOrigin ?? '') + ':' + value;
+	const key = 'preconnect:' + String((options as any)?.crossOrigin) + ':' + value;
 	const safeHref = sanitizeURL(value);
 	emitHeadHint(
 		key,

diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -27808,16 +27808,13 @@
 	const rawHref = guardHintHref('preconnect', href);
 	if (rawHref === null) return;
 	const safeHref = sanitizeURL(rawHref);
-	insertHeadHint(
-		'preconnect:' + String((options as any)?.crossOrigin ?? '') + ':' + rawHref,
-		() => {
-			const l = document.createElement('link');
-			l.rel = 'preconnect';
-			l.href = safeHref;
-			applyHintAttrs(l, options);
-			return l;
-		},
-	);
+	insertHeadHint('preconnect:' + String((options as any)?.crossOrigin) + ':' + rawHref, () => {
+		const l = document.createElement('link');
+		l.rel = 'preconnect';
+		l.href = safeHref;
+		applyHintAttrs(l, options);
+		return l;
+	});
 }
 
 /** React DOM `prefetchDNS(href)` — `<link rel="dns-prefetch">`. */

You can send follow-ups to the cloud agent here.

Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/runtime.ts Resolved
…nguishes omitted CORS

headResourceKind's link/script loop now rejects itemProp like the
hoistable and style-resource paths (microdata wins over the resource
classification), and the preconnect identity separates an omitted
crossOrigin (no CORS) from crossOrigin: '' (anonymous) — distinct
browser connection modes. Addresses both Bugbot findings on #720.

Co-Authored-By: Claude Fable 5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review August 12, 2026 08:38

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: SSR preload skips module cross-guard
    • Added missing cross-guards so SSR preload(as:'script') also checks 'module:' keys and preloadModule also checks 'script:' keys, matching the client's unified executable identity suppression.

Create PR

Or push these changes by commenting:

@cursor push 92d6a5bd80
Preview (92d6a5bd80)
diff --git a/packages/octane/src/runtime.server.ts b/packages/octane/src/runtime.server.ts
--- a/packages/octane/src/runtime.server.ts
+++ b/packages/octane/src/runtime.server.ts
@@ -8094,7 +8094,8 @@
 	// coalesced away when the preinit lands (see the hintHtml delete there).
 	if (HEAD !== null) {
 		if (as === 'style' && HEAD.hints.has('sheet:' + value)) return;
-		if (as === 'script' && HEAD.hints.has('script:' + value)) return;
+		if (as === 'script' && (HEAD.hints.has('script:' + value) || HEAD.hints.has('module:' + value)))
+			return;
 		if (as === 'style' || as === 'script') {
 			let subset: Record<string, unknown> | null = null;
 			for (const k of ['crossOrigin', 'integrity', 'nonce', 'fetchPriority', 'referrerPolicy']) {
@@ -8306,8 +8307,9 @@
 export function preloadModule(href: string, options?: Record<string, unknown>): void {
 	const value = coerceHintHref(href);
 	if (value === null) return;
-	// A module that preinitModule already executed in this pass needs no preload.
-	if (HEAD !== null && HEAD.hints.has('module:' + value)) return;
+	// A module that preinitModule or a Float script already executed in this pass needs no preload.
+	if (HEAD !== null && (HEAD.hints.has('module:' + value) || HEAD.hints.has('script:' + value)))
+		return;
 	const key = 'modulepreload:' + value;
 	const safeHref = sanitizeURL(value);
 	emitHeadHint(

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit cae7135. Configure here.

Comment thread packages/octane/src/runtime.server.ts Resolved
trueadm and others added 2 commits August 12, 2026 10:15
preload(as:'script') and preloadModule now check BOTH executable
namespaces on the server, matching the client's unified identity set —
no redundant classic preload after preinitModule, no redundant
modulepreload after a classic Float script. Addresses the third Bugbot
finding on #720.

Co-Authored-By: Claude Fable 5 <[email protected]>
@trueadm
trueadm merged commit 5377ef3 into main Aug 12, 2026
7 of 22 checks passed
@trueadm
trueadm deleted the feat/react19-float-gaps branch August 12, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant