Skip to content

fix(octane): preserve unchanged trusted HTML child identity - #1278

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/fix-trusted-html-identity
Sep 23, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/fix-trusted-html-identity

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A fresh trustHTML() wrapper with unchanged content currently replaces the host's children on the first render after hydration and on client updates. Cache the accepted HTML string in the owning runtime setter so these renders preserve child identity. Matching hydration seeds the cache; writes and ownership release journal it for rollback. Script text updates retain their existing behavior.

Fixes #1259.

Validation

  • pnpm sync and scoped formatting completed; generated files are unchanged.
  • Targeted repository-configured tests: 364 passed across 22 executions in octane and octane-prod. Covers trusted HTML, raw-HTML validation and source precedence, ownership transitions, script content, hydration mismatches, Suspense preservation, and ViewTransition host state.
  • Scoped typecheck of the runtime and test, plus the JSX fixture using the owning config with JSX enabled.
  • Pre-fix regression: both compile modes replaced identical children. Deliberately omitting cache journaling/invalidation also failed the rollback and empty-HTML ownership regressions.
  • Deterministic operation probe: 20 identical updates reduced native HTML writes from 20 to 0 in client/hydration and dev/prod; alternating-value controls remained 20 writes.
  • Selected production bundle budgets: generic root +249 raw / +17 Brotli bytes; hooks, hydration, and behavior roots unchanged in raw/Brotli size. No timing improvement is claimed.
  • pnpm format:check (repository-wide; scoped formatting used)
  • pnpm typecheck (repository-wide; scoped checks used)
  • pnpm test (repository-wide; affected suites used)

The regression uses the real fixture compiler and SSR/hydration path and asserts child identity. A browser pointer gesture was not separately exercised.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches core dangerouslySetInnerHTML hydration and client update paths with new host state and journaling; behavior is well covered by tests but affects DOM mutation semantics.

Overview
Fixes child identity for unchanged trustHTML() / dangerouslySetInnerHTML content after hydration and on client re-renders, where a fresh wrapper used to replace DOM nodes even when the HTML string was the same.

The runtime now caches the accepted authored HTML on the host (DANGER_HTML_VALUE), seeded when hydration adopts matching markup and updated on real writes. Identical subsequent values skip innerHTML replacement (scripts keep existing text behavior). Cache updates are journaled for staged/rollback renders, and cleared when raw HTML ownership is released so ordinary children can take over.

Tests cover stable nodes across hydrate/update cycles, parser-normalized markup, hydration mismatches (with/without suppression), toggling between raw HTML and ordinary children, and retained markup when a suspended render is abandoned.

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

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 23, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 23, 2026 09:22
@domgan-oai
domgan-oai merged commit 93ddb5a into octanejs:main Sep 23, 2026
50 checks passed
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 fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unchanged trusted HTML replaces child nodes on the first post-hydration render

1 participant