Repository navigation
fix(octane): keep adopted raw HTML until __html changes, as React 19.3 - #2228
Merged
Merged
Conversation
Hydration marks an adopted dangerouslySetInnerHTML element as holding the server's content, still without comparing anything in production. The first write after hydration compares the element's serialization with the render's __html string once: equal content keeps its nodes, as React 19.3 keeps an unchanged string; a mismatch or another spelling is rewritten as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 23, 2026 19:06
Hydration now accepts an adopted dangerouslySetInnerHTML's server content as the client's __html string, still comparing nothing in production, so only a render with a different string rewrites it. This matches React 19.3, which compares the previous __html again (19.0 to 19.2 rewrote on every new wrapper), including a mismatch, which stays until the string changes. Replaces the one-time innerHTML compare from the previous commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 30864fb | Commit Preview URL Branch Preview URL |
Oct 23 2026, 07:13 PM |
Contributor
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
67 other measured values are unchanged. Public-import reachability bundles (bytes)
94 other measured values are unchanged. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 30864fb | Commit Preview URL Branch Preview URL |
Oct 23 2026, 07:13 PM |
This was referenced Oct 23, 2026
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.
Summary
dangerouslySetInnerHTMLnow stays until a render passes a different__htmlstring, as in React 19.3. Previously the first render after hydration reparsed and replaced it, even with the same string.__htmlstring (the raw-HTML cache, journaled like any write). Production still compares nothing, and development still warns about a difference at hydration.__htmlchanges. That reverses fix(octane): preserve unchanged trusted HTML child identity #1278's repair-on-next-render, at the user's request, for React 19.3 parity.Why
Trusted Types browser coverage (#2224) hydrates a page and then re-renders it. Every adopted raw-HTML host was rewritten on that first re-render, even with an unchanged string. Besides the CPU cost, this replaces the nodes, so iframes and media inside the HTML reload and listeners or state that scripts attached inside it are lost. Octane already skipped same-string writes on the client afterwards, and React 19.3 skips them after hydration too.
React probe
Real React with
hydrateRoot, then two same-string re-renders, then a changed string (jsdom,react-dom/servermarkup, inline{__html}wrapper). "kept" means the server's first child node survived:<b>server</b>vs<i>client</i>)<b data-note="&"/>)__htmlafterwardssetPropwritesinnerHTMLwhenever the{__html}object changes, with no compare.prevValue.__html !== nextHtmlagain, which is React 18's behavior.Measurement (headless Chromium, playwright 1.61)
This is what one avoided rewrite costs, for a single raw-HTML host. Each figure is the median of 15 rounds; three runs agreed within about 10%.
<p>(63 B, 3 elements)The change adds no read or compare. Hydration adds one journaled expando write per raw-HTML host. (The first commit compared
el.innerHTMLonce instead, which cost 0.19 / 8.8 / 71 / 358 µs on the same subtrees. The second commit removes that compare.)Changes
runtime/host-props.tssetHTML: the hydration branch recordsDANGER_HTML_VALUE = next, journaled, so a dropped hydrating attempt restores it. The write path is unchanged from main.runtime/hydration.tsadoptHTML: comment only.docs/differences-from-react.md: the hydration bullet now states React 19.3 behavior. Raw HTML follows the same "kept until the client changes it" rule as attributes, and the bullet notes 19.0 to 19.2's rewrite.tests/trusted-html.test.ts:<b>keeps its identity across the first update.suppressHydrationWarning. The server's<b>survives a same-string render, then a changed string writes<i>changed</i>.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkon the 5 changed files passes.pnpm typecheck: not run repo-wide.pnpm typecheck:filesonhost-props.tsandhydration.tspasses. The test file reports 22 TS4111 errors on fixture-moduleclient.Xaccesses, all on lines this change did not add.pnpm test: left to CI (local runs limited to one file in one project).trusted-html.test.tsin--project octane, 10/10 pass, covering dev and prod compile.conformance/hydration-mismatch,conformance/reconnecting-wave4c,hydration/stale-capture-recovery,hydration/*-value-mismatch) assert only the state right after hydration, which is unchanged. A dormant island whose captures changed still hydrates with the server's value and then writes the new string. Left to CI.pnpm sync: no generated changes.perf-review:node scripts/perf-review-scan.mjsfound 0 candidates.setHTMLis the per-write path, unchanged from main. The hydration branch adds onejournalRootPropertycall, which returns early outside a root transaction, and one symbol-expando write per adopted raw-HTML host.must-fixfindings.concise-code: src +9 −8 (runtime code +3 −1; the rest is comments). New files: the changeset only. No new exports. Alternatives:el.innerHTMLonce on the first write (this PR's first commit). About 5 code lines plus a read that costs up to about 18% of a rewrite on a mismatch, and it diverges from 19.3 on mismatches.undefined. It also reads on fresh client mounts, and it is wrong after a raw-HTML → children → raw-HTML switch.full_fwandhydrate-frame. The cost is the journaledDANGER_HTML_VALUEwrite in setHTML's hydration branch. All 64 js-framework work counters are unchanged.Risk / follow-ups
__htmlchanges. This is React 18 and 19.3 behavior, and development already warns at hydration. Applications that relied on the repair need a changed string or akey.<script dangerouslySetInnerHTML>goes throughsetScriptText, which compares the script's text node, so a mismatched inline script is still rewritten on the next render.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Touches hydration and
dangerouslySetInnerHTMLcommit semantics; wrong caching could skip needed DOM updates or leave mismatched HTML longer than before (intentional React 19.3 divergence for mismatches).Overview
Adopted
dangerouslySetInnerHTMLno longer reparses server DOM on the first client render when the render’s__htmlstring matches what hydration recorded.setHTMLnow journals and setsDANGER_HTML_VALUEto that string during hydration adoption, so the existinghost[DANGER_HTML_VALUE] === nextearly return skipsinnerHTMLand preserves server node identity (iframes, listeners, Trusted Types flows).innerHTMLstill runs when the string actually changes. Hydration mismatches keep server markup until__htmlchanges—aligned with React 19.3, documented indocs/differences-from-react.md(vs React 19.0–19.2 rewriting on every new{__html}object).trusted-html.test.tsexpectations updated accordingly.Reviewed by Cursor Bugbot for commit 30864fb. Bugbot is set up for automated code reviews on this repo. Configure here.