Skip to content

feat(octane): support Trusted Types - #2162

Merged
trueadm merged 3 commits into
nextfrom
feat/trusted-types
Oct 20, 2026
Merged

trueadm merged 3 commits into
nextfrom
feat/trusted-types

Conversation

@trueadm

@trueadm trueadm commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Trusted Types support, matching React 19.3. A TrustedHTML, TrustedScript, or TrustedScriptURL passed to dangerouslySetInnerHTML or to an attribute (srcdoc, a script's src, SVG xlinkHref, spreads) now reaches the DOM sink as the object instead of its string.
  • Octane parses some markup itself: compiled templates, binding fragments, and streamed regions. React has no equivalent. That markup now goes through a module-private policy named octane. The streaming bootstrap's JSON carrier uses its own octane-stream policy. Application strings never go through either policy.

Refs #2053. This is the Trusted Types half of the issue; parallel transitions waits for #2043's update queues.

Why

Under require-trusted-types-for 'script', a string written to innerHTML, a script's text, or a script URL throws. Before this PR, Octane's first template parse failed under enforcement. setHTML also called String() on application TrustedHTML, so even correctly typed values were rejected.

Changes

  • src/trusted-types.ts:
    • FRAMEWORK_POLICY is the octane policy, created once at module load with the native String as its rule. It is null without Trusted Types, or when the policy is refused, in which case the sink reports the violation. Sinks read it inline, so a template parse runs no extra script function.
    • trustedOr(value, text) is called only for object values. It returns the object only when it is a Trusted Types value and sanitizing did not replace its text.
  • runtime/host-props.ts:
    • setHTML and setScriptText pass trusted values to innerHTML and textContent, including the deferred commit ops.
    • setAttribute, setPlainAttribute, and setURLAttribute (the prod fast paths) pass trusted values to setAttribute/setAttributeNS.
    • Comparisons and hydration still use the coerced string.
  • Policy routing:
    • runtime/templates.ts, dom-binding-program.ts, and hydration/stream-receiver.ts parse through FRAMEWORK_POLICY.
    • hydration/dev-values.ts parses the value it receives, so dev hydration comparison works under enforcement.
  • runtime.server.ts: the $OCTRC JSON carrier creates octane-stream on first use. This adds about 170 raw bytes to the inline stream runtime, sent only when a boundary is pending.
  • Docs:
    • a new "Trusted Types" section in docs/differences-from-react.md, covering the policy names, the TrustedScript requirement for <script dangerouslySetInnerHTML>, that only TT objects pass through, and that Float URLs stay strings;
    • the design doc's "future integration" note is now resolved.
  • Changeset: octane minor.

Validation

  • pnpm format:files:check (all changed files)
  • pnpm typecheck:files on every changed source, test, and fixture file
  • pnpm test: not run locally (machine load rule). Left to CI.
  • targeted tests:
    • tests/conformance/trusted-types.test.ts, 7 cases, passes in octane and octane-prod (14/14). It is modelled on React's trustedTypes-test.internal.js: a fake trustedTypes global and spies that assert the identical object reaches innerHTML, textContent, setAttribute, and setAttributeNS. It also checks:

      • one octane policy is created for templates;
      • a javascript: TrustedScriptURL is written as the sanitized string;
      • ordinary objects are still stringified exactly once;
      • dev hydration with trusted values produces no mismatch.

      With the src change reverted, the 4 passthrough and policy cases fail.

    • tests/browser/trusted-types/trusted-types.test.ts (octane-events-browser, Chromium, dev and prod bundles) passes 2/2. The page is served with an enforced require-trusted-types-for 'script'; trusted-types octane octane-stream app and no default policy. The test checks:

      • a client mount and update through templates, TrustedHTML dangerouslySetInnerHTML, srcdoc, and script src;
      • a streamed @try boundary whose raw HTML contains </template>, which forces the JSON carrier;
      • a plain application string is rejected by the browser, and it is the only CSP violation.

      With the src change reverted, both cases time out. With only the bootstrap change reverted, the streamed boundary never reveals.

  • perf-review: node scripts/perf-review-scan.mjs, 0 candidates. Hot paths touched:
    • attribute writes (setAttribute/setPlainAttribute/setURLAttribute, per attribute write) and setHTML gain one inline typeof value === 'object' test. Only object values (for example URL) call trustedOr, which costs three native isX calls in browsers with Trusted Types.
    • parseTemplate: once per template, one native createHTML where Trusted Types exists, with no script call.
    • The first push failed the js-framework work gate: calls_run rose by 2 (the lazy frameworkHTML plus its (s) => s rule). The second commit removes both calls.
    • No new fields, closures, or allocation per render, and no scheduling change.
    • needs-evidence: client bundle rows from the CI bench report (expected under 0.2 kB gz for the new module).
  • concise-code:
    • src +79 −20, all client runtime except the ~170 raw bytes of inline server bootstrap.
    • New file: src/trusted-types.ts, shared by four importers: host-props, templates, dom-binding-program, and stream-receiver.
    • New exports: FRAMEWORK_POLICY and trustedOr, each with callers.
    • Alternatives rejected:
      • Passing every object through, as React does, would break Octane's toString-once invariant and bypass URL sanitizing.
      • A single policy name shared by the bootstrap and the client would make the client's createPolicy throw without 'allow-duplicates'.
      • Exposing the bootstrap policy on window would let any script use it to launder strings.
    • Bytes: see CI rows.

Risk / follow-ups

  • Not covered by this PR, all documented as current behavior:
    • Float resource URLs (preinit/preload, hoisted async scripts in runtime/head.ts) still take strings, as in React.
    • The binding-view renderer's attribute writes (dom-bindings.ts) receive pre-coerced strings.
  • A page that loads two Octane copies needs 'allow-duplicates'. This is documented.
  • SSR output is unchanged.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


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


Note

Medium Risk
Touches core DOM write paths (innerHTML, attributes, streaming bootstrap) and CSP-sensitive sinks; behavior is well-tested but any mistake could break rendering or weaken URL sanitization for non-TT values.

Overview
Adds Trusted Types support aligned with React 19.3 so apps can run under require-trusted-types-for 'script'.

Application-authored values: TrustedHTML, TrustedScript, and TrustedScriptURL passed to dangerouslySetInnerHTML, script bodies, and sinks like srcdoc / script src / SVG xlinkHref are written to the DOM as the object, not String(value). Sanitized URLs (e.g. blocked javascript:) still write the string. Ordinary objects keep a single stringify, unlike React’s pass-through for all objects.

Framework-generated markup: Compiled templates, binding fragments, and streamed placement HTML parse through a lazy octane policy (frameworkHTML). The streaming bootstrap’s JSON carrier uses a separate inline octane-stream policy in $OCTRC. CSP trusted-types must allow both; app strings never use these policies.

Docs mark Trusted Types as implemented (new section in differences-from-react.md). Conformance and Playwright browser tests cover sinks, hydration, streaming boundaries, and enforced CSP.

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

A TrustedHTML, TrustedScript, or TrustedScriptURL passed to
dangerouslySetInnerHTML or an attribute now reaches its DOM sink as the
object, as in React 19.3, so it works under an enforced
require-trusted-types-for 'script' CSP.

Markup Octane parses itself (compiled templates, binding fragments,
streamed regions) goes through a module-private `octane` policy, and the
streaming bootstrap's JSON carrier through `octane-stream`. Application
strings never go through either.

Refs #2053.

Co-Authored-By: Claude Opus 5.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 Oct 20, 2026
@trueadm
trueadm marked this pull request as ready for review October 20, 2026 11:24
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website-mcp 80b1285 Commit Preview URL

Branch Preview URL
Oct 20 2026, 11:42 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website 80b1285 Commit Preview URL

Branch Preview URL
Oct 20 2026, 11:43 AM

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 75 value(s) increased
  • 🔴 bundle-reachability: 84 value(s) increased

Compares 5e7cff321, the merge commit's first parent with f4d7af128 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.858 3.183 −1.7% −8.0% … +0.0% ⚪ within noise
octane-tsrx replace 5.725 6.075 −2.5% −7.1% … +1.8% ⚪ within noise
octane-tsrx add 2.625 2.525 −4.0% −6.0% … +0.0% ⚪ within noise
octane-tsrx update 0.088 0.096 −1.9% −3.6% … +1.8% ⚪ within noise
octane-tsrx select 0.007 0.008 +1.5% −3.9% … +11.3% ⚪ within noise
octane-tsrx swap 0.021 0.023 −4.3% −8.4% … +0.0% ⚪ within noise
octane-tsrx remove 0.017 0.019 ±0.0% −6.0% … +4.1% ⚪ within noise
octane-tsrx runlots 25.700 24.800 −2.7% −5.3% … +2.9% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 +1.0% −0.5% … +3.3% ⚪ within noise
octane-tsrx clear 39.017 40.875 +2.6% −0.8% … +5.8% ⚪ within noise
octane-jsx run 5.500 7.008 +5.1% −4.1% … +48.3% ⚪ within noise
octane-jsx replace 9.075 9.408 +0.7% −3.7% … +9.8% ⚪ within noise
octane-jsx add 4.383 4.808 +1.3% −5.8% … +8.8% ⚪ within noise
octane-jsx update 0.232 0.222 −5.1% −10.5% … −1.0% ⚪ within noise
octane-jsx select 0.126 0.127 −1.2% −16.4% … +4.0% ⚪ within noise
octane-jsx swap 0.176 0.184 −4.9% −11.0% … +10.7% ⚪ within noise
octane-jsx remove 0.155 0.142 −0.3% −11.1% … +5.8% ⚪ within noise
octane-jsx runlots 36.158 35.425 +2.1% −4.0% … +4.7% ⚪ within noise
octane-jsx select_lots 1.191 1.235 +4.8% −2.3% … +18.3% ⚪ within noise
octane-jsx clear 46.975 43.825 +0.6% −4.5% … +4.1% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx js_raw 86,353 86,526 +173 (+0.2%) 🔴
octane-tsrx js_gzip 29,135 29,209 +74 (+0.3%) 🔴
octane-tsrx js_brotli 26,281 26,376 +95 (+0.4%) 🔴
octane-tsrx fw_raw 78,859 79,032 +173 (+0.2%) 🔴
octane-tsrx fw_gzip 26,538 26,612 +74 (+0.3%) 🔴
octane-tsrx fw_brotli 24,022 24,117 +95 (+0.4%) 🔴
octane-tsrx todo_js_raw 99,171 99,344 +173 (+0.2%) 🔴
octane-tsrx todo_js_gzip 33,797 33,871 +74 (+0.2%) 🔴
octane-tsrx todo_js_brotli 30,249 30,260 +11 (+0.0%) 🔴
octane-tsrx todo_app_brotli 2,305 2,308 +3 (+0.1%) 🔴
octane-tsrx todo_fw_raw 93,008 93,181 +173 (+0.2%) 🔴
octane-tsrx todo_fw_gzip 31,050 31,124 +74 (+0.2%) 🔴
octane-tsrx todo_fw_brotli 27,944 27,952 +8 (+0.0%) 🔴
octane-tsrx chat_js_raw 97,951 98,122 +171 (+0.2%) 🔴
octane-tsrx chat_js_gzip 33,511 33,564 +53 (+0.2%) 🔴
octane-tsrx chat_js_brotli 30,093 30,159 +66 (+0.2%) 🔴
octane-tsrx chat_app_brotli 2,760 2,761 +1 (+0.0%) 🔴
octane-tsrx chat_fw_raw 90,961 91,132 +171 (+0.2%) 🔴
octane-tsrx chat_fw_gzip 30,341 30,394 +53 (+0.2%) 🔴
octane-tsrx chat_fw_brotli 27,333 27,398 +65 (+0.2%) 🔴
octane-tsrx weather_js_raw 136,285 136,454 +169 (+0.1%) 🔴
octane-tsrx weather_js_gzip 45,310 45,382 +72 (+0.2%) 🔴
octane-tsrx weather_js_brotli 40,263 40,270 +7 (+0.0%) 🔴
octane-tsrx weather_app_gzip 8,571 8,572 +1 (+0.0%) 🔴
octane-tsrx weather_app_brotli 7,242 7,247 +5 (+0.1%) 🔴
octane-tsrx weather_fw_raw 111,422 111,591 +169 (+0.2%) 🔴
octane-tsrx weather_fw_gzip 36,739 36,810 +71 (+0.2%) 🔴
octane-tsrx weather_fw_brotli 33,021 33,023 +2 (+0.0%) 🔴
octane-tsrx bindings_js_raw 683,131 683,563 +432 (+0.1%) 🔴
octane-tsrx bindings_js_gzip 226,148 226,329 +181 (+0.1%) 🔴
octane-tsrx bindings_js_brotli 192,702 192,866 +164 (+0.1%) 🔴
octane-tsrx bindings_app_brotli 96,847 96,788 −59 (−0.1%) 🟢
octane-tsrx bindings_fw_raw 331,329 331,761 +432 (+0.1%) 🔴
octane-tsrx bindings_fw_gzip 109,589 109,770 +181 (+0.2%) 🔴
octane-tsrx bindings_fw_brotli 95,855 96,078 +223 (+0.2%) 🔴
octane-tsrx wayfinder_js_raw 437,239 437,753 +514 (+0.1%) 🔴
octane-tsrx wayfinder_js_gzip 144,456 144,694 +238 (+0.2%) 🔴
octane-tsrx wayfinder_js_brotli 126,147 126,372 +225 (+0.2%) 🔴
octane-tsrx threadline_oxc_js_raw 153,297 153,641 +344 (+0.2%) 🔴
octane-tsrx threadline_oxc_js_gzip 50,721 50,846 +125 (+0.2%) 🔴
octane-tsrx threadline_oxc_js_brotli 44,689 44,817 +128 (+0.3%) 🔴
octane-tsrx threadline_esbuild_js_raw 178,138 178,486 +348 (+0.2%) 🔴
octane-tsrx threadline_esbuild_js_gzip 59,845 59,978 +133 (+0.2%) 🔴
octane-tsrx threadline_esbuild_js_brotli 52,682 52,775 +93 (+0.2%) 🔴
octane-tsrx pagecraft_oxc_js_raw 544,342 544,795 +453 (+0.1%) 🔴
octane-tsrx pagecraft_oxc_js_gzip 171,281 171,427 +146 (+0.1%) 🔴
octane-tsrx pagecraft_oxc_js_brotli 145,498 145,539 +41 (+0.0%) 🔴
octane-tsrx pagecraft_esbuild_js_raw 576,769 577,228 +459 (+0.1%) 🔴
octane-tsrx pagecraft_esbuild_js_gzip 186,581 186,781 +200 (+0.1%) 🔴
octane-tsrx pagecraft_esbuild_js_brotli 158,623 158,869 +246 (+0.2%) 🔴
octane-tsrx full_fw_raw 522,995 523,448 +453 (+0.1%) 🔴
octane-tsrx full_fw_gzip 163,325 163,487 +162 (+0.1%) 🔴
octane-tsrx full_fw_brotli 138,999 139,150 +151 (+0.1%) 🔴
octane-jsx js_raw 162,514 162,921 +407 (+0.3%) 🔴
octane-jsx js_gzip 53,050 53,205 +155 (+0.3%) 🔴
octane-jsx js_brotli 46,869 47,059 +190 (+0.4%) 🔴
octane-jsx app_brotli 2,890 2,894 +4 (+0.1%) 🔴
octane-jsx fw_raw 151,539 151,946 +407 (+0.3%) 🔴
octane-jsx fw_gzip 49,494 49,649 +155 (+0.3%) 🔴
octane-jsx fw_brotli 43,979 44,165 +186 (+0.4%) 🔴
octane-jsx shell_js_raw 327,352 327,763 +411 (+0.1%) 🔴
octane-jsx shell_js_gzip 106,673 106,840 +167 (+0.2%) 🔴
octane-jsx shell_js_brotli 92,633 92,663 +30 (+0.0%) 🔴
octane-jsx shell_app_gzip 765 763 −2 (−0.3%) 🟢
octane-jsx shell_app_brotli 653 654 +1 (+0.2%) 🔴
octane-jsx shell_fw_raw 326,259 326,670 +411 (+0.1%) 🔴
octane-jsx shell_fw_gzip 105,908 106,077 +169 (+0.2%) 🔴
octane-jsx shell_fw_brotli 91,980 92,009 +29 (+0.0%) 🔴
octane-jsx shell_client_js_raw 278,745 279,156 +411 (+0.1%) 🔴
octane-jsx shell_client_js_gzip 90,297 90,454 +157 (+0.2%) 🔴
octane-jsx shell_client_js_brotli 78,985 79,099 +114 (+0.1%) 🔴
octane-jsx shell_client_app_brotli 668 654 −14 (−2.1%) 🟢
octane-jsx shell_client_fw_raw 277,644 278,055 +411 (+0.1%) 🔴
octane-jsx shell_client_fw_gzip 89,526 89,683 +157 (+0.2%) 🔴
octane-jsx shell_client_fw_brotli 78,317 78,445 +128 (+0.2%) 🔴
octane-jsx full_fw_raw 522,995 523,448 +453 (+0.1%) 🔴
octane-jsx full_fw_gzip 163,325 163,487 +162 (+0.1%) 🔴
octane-jsx full_fw_brotli 138,999 139,150 +151 (+0.1%) 🔴

15 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
cli-spa-starter raw 78,682 79,009 +327 (+0.4%) 🔴
cli-spa-starter gzip 27,273 27,409 +136 (+0.5%) 🔴
cli-spa-starter brotli 24,492 24,622 +130 (+0.5%) 🔴
root-static-specialized raw 50,952 51,121 +169 (+0.3%) 🔴
root-static-specialized gzip 17,461 17,534 +73 (+0.4%) 🔴
root-static-specialized brotli 15,883 15,960 +77 (+0.5%) 🔴
root-chained-jsx raw 53,090 53,263 +173 (+0.3%) 🔴
root-chained-jsx gzip 18,163 18,229 +66 (+0.4%) 🔴
root-chained-jsx brotli 16,552 16,601 +49 (+0.3%) 🔴
root-static raw 138,170 138,577 +407 (+0.3%) 🔴
root-static gzip 45,280 45,423 +143 (+0.3%) 🔴
root-static brotli 40,330 40,449 +119 (+0.3%) 🔴
root-static-local raw 50,853 51,022 +169 (+0.3%) 🔴
root-static-local gzip 17,415 17,483 +68 (+0.4%) 🔴
root-static-local brotli 15,853 15,926 +73 (+0.5%) 🔴
root-callback-local raw 53,507 53,680 +173 (+0.3%) 🔴
root-callback-local gzip 18,270 18,336 +66 (+0.4%) 🔴
root-callback-local brotli 16,642 16,697 +55 (+0.3%) 🔴
hooks-state raw 61,857 62,030 +173 (+0.3%) 🔴
hooks-state gzip 21,073 21,147 +74 (+0.4%) 🔴
hooks-state brotli 19,158 19,228 +70 (+0.4%) 🔴
prop-attributes raw 58,963 59,311 +348 (+0.6%) 🔴
prop-attributes gzip 20,222 20,350 +128 (+0.6%) 🔴
prop-attributes brotli 18,396 18,523 +127 (+0.7%) 🔴
context raw 69,644 69,817 +173 (+0.2%) 🔴
context gzip 23,424 23,481 +57 (+0.2%) 🔴
context brotli 21,218 21,264 +46 (+0.2%) 🔴
hydrate-root raw 96,305 96,478 +173 (+0.2%) 🔴
hydrate-root gzip 32,410 32,471 +61 (+0.2%) 🔴
hydrate-root brotli 28,941 29,050 +109 (+0.4%) 🔴
deferred-hydration raw 180,297 180,466 +169 (+0.1%) 🔴
deferred-hydration gzip 58,802 58,879 +77 (+0.1%) 🔴
deferred-hydration brotli 51,352 51,445 +93 (+0.2%) 🔴
hydrate-frame raw 340,555 340,968 +413 (+0.1%) 🔴
hydrate-frame gzip 109,372 109,507 +135 (+0.1%) 🔴
hydrate-frame brotli 94,986 95,159 +173 (+0.2%) 🔴
suspense-transition raw 115,432 115,601 +169 (+0.1%) 🔴
suspense-transition gzip 37,745 37,813 +68 (+0.2%) 🔴
suspense-transition brotli 33,587 33,604 +17 (+0.1%) 🔴
component-owned-effects raw 55,035 55,205 +170 (+0.3%) 🔴
component-owned-effects gzip 18,794 18,860 +66 (+0.4%) 🔴
component-owned-effects brotli 17,132 17,193 +61 (+0.4%) 🔴
descriptor-children raw 159,813 160,051 +238 (+0.1%) 🔴
descriptor-children gzip 51,938 52,015 +77 (+0.1%) 🔴
descriptor-children brotli 46,205 46,311 +106 (+0.2%) 🔴
binding-hooks raw 64,256 64,429 +173 (+0.3%) 🔴
binding-hooks gzip 22,087 22,157 +70 (+0.3%) 🔴
binding-hooks brotli 20,072 20,143 +71 (+0.4%) 🔴
split-shell raw 391,381 391,792 +411 (+0.1%) 🔴
split-shell gzip 127,463 127,625 +162 (+0.1%) 🔴
split-shell brotli 111,143 111,289 +146 (+0.1%) 🔴
split-shell-runtime raw 316,283 316,694 +411 (+0.1%) 🔴
split-shell-runtime gzip 101,749 101,911 +162 (+0.2%) 🔴
split-shell-runtime brotli 88,010 88,153 +143 (+0.2%) 🔴
binding-base-ui-vite raw 170,321 170,559 +238 (+0.1%) 🔴
binding-base-ui-vite gzip 55,558 55,647 +89 (+0.2%) 🔴
binding-base-ui-vite brotli 49,384 49,439 +55 (+0.1%) 🔴
binding-base-ui-esbuild raw 198,522 198,760 +238 (+0.1%) 🔴
binding-base-ui-esbuild gzip 66,697 66,788 +91 (+0.1%) 🔴
binding-base-ui-esbuild brotli 58,950 59,092 +142 (+0.2%) 🔴
binding-radix-vite raw 169,765 170,003 +238 (+0.1%) 🔴
binding-radix-vite gzip 55,244 55,332 +88 (+0.2%) 🔴
binding-radix-vite brotli 49,021 49,108 +87 (+0.2%) 🔴
binding-radix-esbuild raw 198,010 198,248 +238 (+0.1%) 🔴
binding-radix-esbuild gzip 66,385 66,466 +81 (+0.1%) 🔴
binding-radix-esbuild brotli 58,634 58,671 +37 (+0.1%) 🔴
binding-mantine-hooks-vite raw 63,195 63,368 +173 (+0.3%) 🔴
binding-mantine-hooks-vite gzip 21,728 21,801 +73 (+0.3%) 🔴
binding-mantine-hooks-vite brotli 19,741 19,792 +51 (+0.3%) 🔴
binding-mantine-hooks-esbuild raw 77,783 77,956 +173 (+0.2%) 🔴
binding-mantine-hooks-esbuild gzip 27,593 27,668 +75 (+0.3%) 🔴
binding-mantine-hooks-esbuild brotli 24,893 25,031 +138 (+0.6%) 🔴
binding-apollo-client-vite raw 315,064 315,471 +407 (+0.1%) 🔴
binding-apollo-client-vite gzip 98,489 98,660 +171 (+0.2%) 🔴
binding-apollo-client-vite brotli 87,197 87,349 +152 (+0.2%) 🔴
binding-apollo-client-esbuild raw 350,461 350,872 +411 (+0.1%) 🔴
binding-apollo-client-esbuild gzip 113,694 113,852 +158 (+0.1%) 🔴
binding-apollo-client-esbuild brotli 100,224 100,562 +338 (+0.3%) 🔴
binding-usehooks-ts-vite raw 63,977 64,150 +173 (+0.3%) 🔴
binding-usehooks-ts-vite gzip 21,966 22,038 +72 (+0.3%) 🔴
binding-usehooks-ts-vite brotli 19,956 20,003 +47 (+0.2%) 🔴
binding-usehooks-ts-esbuild raw 78,551 78,724 +173 (+0.2%) 🔴
binding-usehooks-ts-esbuild gzip 27,845 27,910 +65 (+0.2%) 🔴
binding-usehooks-ts-esbuild brotli 25,175 25,216 +41 (+0.2%) 🔴

39 other measured values are unchanged.

trueadm and others added 2 commits October 20, 2026 12:40
…o extra calls

The js-framework work gate counted two more calls per template parse in
Chromium: frameworkHTML and the policy's `(s) => s` rule. Create the
`octane` policy once at module load with the native `String` as its rule
and read it inline at each sink, and call trustedOr only for object
values, so primitive attribute and HTML writes make no extra call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm merged commit 424e5cc into next Oct 20, 2026
29 checks passed
@trueadm
trueadm deleted the feat/trusted-types branch October 20, 2026 13:26
trueadm added a commit that referenced this pull request Oct 23, 2026
* feat(octane): support Trusted Types

Re-lands #2162. It merged into `next` on 2026-10-20, after #2103 had
already integrated `next` into `main`, and `next` was then deleted, so
the change never reached `main`. This is the #2162 squash commit
(424e5cc) cherry-picked onto `main` without changes.

A TrustedHTML, TrustedScript, or TrustedScriptURL passed to
dangerouslySetInnerHTML or an attribute now reaches its DOM sink as the
object, as in React 19.3, so it works under an enforced
require-trusted-types-for 'script' CSP.

Markup Octane parses itself (compiled templates, binding fragments,
streamed regions) goes through a module-private `octane` policy, created
at module load with the native `String` as its rule, and the streaming
bootstrap's JSON carrier through `octane-stream`. Application strings
never go through either.

Refs #2053.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(octane): type the Trusted Types browser fixture

main's test config rejects reading a server fixture's export through its
index signature, so name the fixture module type, as other tests do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(octane): write changed script text through its Trusted Types sink

setScriptText updated an existing Text node in place, so after the first
write a TrustedScript never reached the script's textContent sink, and
under enforcement a string update was not rejected. An unchanged body
still writes nothing; a changed one now always assigns textContent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 23, 2026
…aries and deferred activation (#2224)

* feat(octane): support Trusted Types

Re-lands #2162. It merged into `next` on 2026-10-20, after #2103 had
already integrated `next` into `main`, and `next` was then deleted, so
the change never reached `main`. This is the #2162 squash commit
(424e5cc) cherry-picked onto `main` without changes.

A TrustedHTML, TrustedScript, or TrustedScriptURL passed to
dangerouslySetInnerHTML or an attribute now reaches its DOM sink as the
object, as in React 19.3, so it works under an enforced
require-trusted-types-for 'script' CSP.

Markup Octane parses itself (compiled templates, binding fragments,
streamed regions) goes through a module-private `octane` policy, created
at module load with the native `String` as its rule, and the streaming
bootstrap's JSON carrier through `octane-stream`. Application strings
never go through either.

Refs #2053.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(octane): type the Trusted Types browser fixture

main's test config rejects reading a server fixture's export through its
index signature, so name the fixture module type, as other tests do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(octane): write changed script text through its Trusted Types sink

setScriptText updated an existing Text node in place, so after the first
write a TrustedScript never reached the script's textContent sink, and
under enforcement a string update was not rejected. An unchanged body
still writes nothing; a changed one now always assigns textContent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(octane): cover Trusted Types hydration, streamed table/SVG boundaries and deferred activation

Run the enforced `require-trusted-types-for 'script'` browser suite, which
has no default policy, over the cases the streaming design doc lists:
hydrateRoot of renderToString output, a streamed page whose <tbody> and
<svg> boundaries reveal after the shell hydrates, and a deferred
<Hydrate> boundary that a click activates. Each page then mounts fresh
table and SVG content and rewrites its adopted dangerouslySetInnerHTML.
A report-only run checks that the same pages raise no violations.

Each case passes in dev and prod bundles and fails when the template,
stream-bootstrap, setHTML or dev hydration-compare sink writes a string.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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