Repository navigation
perf(bindings): adopt URL channels with the scalar adopter - #1525
Merged
Merged
Conversation
Fixed-node `'use dom bindings'` views that bind a URL attribute now compile to `__adoptScalarBindings` instead of the general adopter. The compiler attaches a `__bindingURL` capability (accept, normalize and write through the existing general channel rules) only to artifacts that bind a URL, so URL-free views never load the sanitizer. The scalar adopter still refuses a URL descriptor without that capability. URL publications now join the legacy hydration handoff in both adopters, publishing the value actually left in the DOM. Previously an early binding's URL update was reverted when the application hydrated, while its other attributes were kept. Refs #1284. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 1, 2026 23:23
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)
All 20 timed operations (16 within noise)
Application bundle size (bytes)No changes across 45 measured values. Public-import reachability bundles (bytes)No changes across 105 measured values. CI job durations
Compares the CI run for
All 26 timed jobs
|
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
'use dom bindings'views that bind a URL attribute (href,src,action,formAction,xlink:href, …) now compile to the scalar adopter instead of the general one. A URL view adopted throughadoptBindingsdrops from 5,732 to 3,872 B gzip (−32%).hydrateRootreverted it to the rendered value.Closes #1284. This is the last increment of proposal 4. The re-measurement and decisions comment covers everything else; follow-ups were split into #1513 and #1514.
Why
#1286 gave fixed scalar views (
attr,boolean,aria,class,text) a lean adopter. A single URL channel still sent a view to the general adopter, which carries projections, controls, class groups, style restoration, host handoff and addressed topology. URL handling only needs one more normalizer and writer, both already indom-bindings.ts.The hydration gap turned up while checking parity. Both adopters publish the values they wrote to the legacy claim map, which
hydrateRootconsults (allowAttribute) so it doesn't overwrite a newer early publication. URL channels were left out of that list, so after an earlyhrefupdate, hydration with the older props restored the oldhrefwhile keeping the adoptedtitle.Changes
dom-bindings.ts__bindingURL: a[accepts, normalize, write]tuple that reuses the existing general channel rules, so URL semantics keep a single source.__adoptScalarBindingstakes all three hooks fromdescriptor.url, falling back to the fixed scalar ones. It still refuses a URL descriptor without the capability (error 330), so version skew can't write an unsanitized URL.write/writeFixedScalarreturn the value left in the DOM. Both adopters publish that value, and URL channels now join the handoff. An empty URL that the writer removes (an emptysrc, orhrefon anything but<a>) is therefore published as an absent attribute, which is what hydration compares against.compiler/dom-bindings.js:urljoins the scalar-adopter channel set.scalarURL(plan)imports__bindingURLand setsurlon the descriptor, at both emission sites: adopt-only artifacts, and the scalar SSR adoption inside mountable artifacts.verify-dist.mjs: the published build must export__bindingURL.Measurements
Production esbuild bundles: minify, tree shaking, ESM, browser,
NODE_ENV=production, gzip-9 / Brotli-11. The baseline is this branch's merge baseb5277d166, built from agit archiveofpackages/octane. Each consumer is a compiled.tsrxview plus a compiled activation module callingadoptBindings(andmountBindingswhere noted).href+ text view<img src>+<svg><use href>href+ text, adopt + mountPrimaryAction(no URL)title+ text view (no URL)title+ text, adopt + mount (no URL).tsrxsignal state + handle view (structural program)export { __adoptBindings }export { createRoot } from 'octane'export { createScope, query } from 'octane/signals'url.createRootand the signals engine are unchanged.CI ratio guard (
bundle-boundaries.test.mjs, selected/general gzip): Scalar 0.50 adopt-only / 0.82 mountable (ceilings 0.6 / 0.88); Link 0.57 / 0.82 (ceilings 0.65 / 0.88).Validation
packages/octane/tests/scalar-dom-bindings.test.ts, run through both the scalar and the general adopter, dev and prod compile,octaneandoctane-prodprojects:javascript:blocking (including leading controls and embedded newlines), empty-URL rules (kept on<a href>, removed elsewhere), removal, signal-handle URLs updating without a source read, and teardown;src, with no mismatch report;Pre-fix failure: with
urlleft out of the general adopter's handoff (the previous behavior), the general lanes of the hydration test fail.Mutation checks, each applied alone and reverted, all caught:
urlout of the handoffurlpublicationurlas a plain attributeurlwithout the capabilitybenchmarks/scoped-signals/bundle-boundaries.test.mjs(runs inci:workflow:test): 30/30. The fixed-scalar guard now requires URL views to select the scalar adopter and keepsanitize-url.js, URL-free adopt-only views to emit zero sanitizer bytes, and per-view gzip ratio ceilings. It still checks identical DOM traces against the general adopter, adopt-only and mountable.Nearby suites:
binding-handoff,behavior-root,behavior-handoff-bundle,hydration/range-boundary,hydration/text-sibling-hydrate, and compilerbundler-compiler,compiler-vite-options,native-reads,production-bundle,typescript-text-inference.pnpm --filter octane build: dist built, imports verified, and__bindingURLpresent in the browser and Node builds.pnpm format:checkandpnpm typecheck(repo-wide, after the first base merge), pluspnpm sync(no changes). After the final base merge: scopedpnpm typecheck:files, the targeted suites above and the bundle guard, all passing.pnpm test(repo-wide): left to CI.Risk / follow-ups
writenow returns the published value. Other callers (__writeBindingin programs, styles, projections) ignore it.behavior-roottextarea retirement tests can exceed the 5 s default timeout. They take 0.5–5.6 s each on unmodifiedmaintoo, and pass in isolation.numberin a binding text hole can't adopt its SSR output. Pre-existing, separate.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes binding codegen, URL sanitization wiring, and hydration handoff for URL attributes; incorrect capability or claim publication could affect security or hydration mismatches.
Overview
Fixed-node
'use dom bindings'views that bind URL attributes (href,src, etc.) now compile to the scalar adopter instead of the full general adopter. The compiler attaches aurlcapability (__bindingURL) only when the view needs it, so URL-free bundles do not pull insanitize-url.js; adopt-only URL views are roughly 32% smaller gzip.__adoptScalarBindingsdelegates normalize/write to that capability while still rejecting URL bindings without it. Both adopters now publish the value left in the DOM (not just the normalized snapshot) into the legacy claim map for scalar and URL channels, sohydrateRootkeeps early-adopted URL updates instead of reverting to SSR props.Bundle-boundary tests and scalar DOM binding tests cover sanitizer inclusion, gzip ratios, sanitization, and hydration parity.
Reviewed by Cursor Bugbot for commit 05b76a8. Bugbot is set up for automated code reviews on this repo. Configure here.