Repository navigation
perf(bindings): select a scalar-only adopter for fixed-node DOM bindings - #1286
Merged
Merged
Conversation
Fixed-node 'use dom bindings' views whose channels are all attr, boolean, aria, class or text now compile to __adoptScalarBindings. It shares node resolution, channel claims, legacy claim publication, the signal connector and native transition preview with __adoptBindings, but retains none of the projection, control, class-group, style-restoration, host-handoff, addressed topology or URL-sanitization code. The general adopter keeps its behavior and remains the compatibility entry for earlier artifacts. Refs #1284 (proposal 4). Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
September 23, 2026 18:28
12 tasks done
This was referenced Oct 1, 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
'use dom bindings'views whose channels are allattr,boolean,aria,classortextnow compile to a new__adoptScalarBindingsinstead of__adoptBindings. This covers both adopt-only artifacts and the scalar SSR adoption inside mountable artifacts.adoptBindingsexample (PrimaryAction) drops from 5,864 to 3,458 B gzip (−41%). Views with any other channel keep the general adopter.Refs #1284 (proposal 4; triage and measurements in this comment).
Why
__adoptBindingsis one function that handles every capability: projections, controls, class groups, style restoration, host handoff, addressed topology and URL sanitization. Every fixed-node consumer shipped all of it. For a text/attribute view it was 12.6 KB of a 15.2 KB bundle. The compiler already knows each descriptor's channel kinds and capabilities, so it can prove when none of that is needed.Changes
dom-bindings.ts:normalize,writeand node resolution (normalizeFixedScalar,writeFixedScalar,resolveFixedNodes). The general functions delegate to these, so each rule has one source.__adoptScalarBindings. It keeps the lifecycle of the general adopter:__claimBinding/__releaseBinding) and legacy claim publication;addressed,handofforconnectProjectionbefore claiming or subscribing. Version skew or misuse therefore can't write an unsanitized URL or drop ownership behavior.compiler/dom-bindings.js:scalarAdopter(plan)picks the entry at both emission sites. Richer channels, addressed targets, host handoff, styles and grouped projections keep__adoptBindings.__adoptBindingsbehavior is unchanged. It remains the compatibility entry for earlier compiler output.verify-dist.mjs: the new export is required in the published build.Measurements
Production esbuild bundles (minified,
NODE_ENV=production, gzip-9 / Brotli-11). The baseline is this branch's base0185cb217, built from agit archiveofpackages/octane/src:PrimaryActionviaadoptBindingstitle+ text view viaadoptBindingsmountBindings(program)export { __adoptBindings }export { __adoptBindingProgram, __mountBindingProgram }Views that keep the general adopter pay +22 to +39 B gzip for the helper split, the cost of keeping one source for scalar normalization and writes instead of duplicating it.
Update timing (supplementary: happy-dom, one process, 20,000 five-channel updates, 10 alternating samples per lane, text checked afterwards): baseline general 871 ns/update, candidate general 869, candidate scalar 842. The delegation adds no measurable cost. This is not browser layout or paint evidence.
Validation
New
packages/octane/tests/scalar-dom-bindings.test.ts: the same compiled artifact runs through the scalar adopter and through__adoptBindings(dev and prod compile,octaneandoctane-prodprojects). Scenarios:subscribeand disposal duringgetSnapshot;binding-handoff.test.tsnow also runs every scenario on a style-free fixture, which takes the scalar adopter. The scenarios cover renderer hydration over adopted nodes, abort, text coercion and claim release.Mutation checks (each applied alone, then reverted). Caught:
The one survivor removed a re-check that the next line repeats (an equivalent mutant).
benchmarks/scoped-signals/bundle-boundaries.test.mjs(runs inci:workflow:test) gets a new guard. It compiles a fixed scalar view and a URL view, both adopt-only and mountable. For each it bundles the selected artifact and a legacy artifact that swaps back to__adoptBindings, then checks:Nearby suites:
behavior-root,behavior-root-bundle,universal-host-bindings,universal-host-binding-retention,hydration/range-boundary,hydration/text-sibling-hydrate, plus compilerbundler-compiler,production-bundle,compiler-vite-options,typescript-text-inferenceandnative-reads. 607 passed across 17 files and projects.pnpm --filter octane build: dist built and imports verified, including the new export.pnpm typecheck:fileson the changed and new files,pnpm format:files:checkon the changed files,pnpm changeset:checkandpnpm sync.pnpm test,pnpm typecheckandpnpm format:check(repo-wide): left to CI.Risk / follow-ups
urlandclassToken(small follow-ups), style channels (restoreStylesis a runtime option), host handoff, addressed topology, controls and class groups. Reduce runtime reachability for scoped signals and fixed-node bindings #1284 asks for eligibility to grow one class at a time with its own controls.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Introduces a second DOM adoption path where compile-time or runtime mis-selection could diverge from general binding behavior or bypass URL sanitization; mitigated by compiler proof, runtime refusal guards, and parity/bundle tests.
Overview
Fixed-node
'use dom bindings'views whose channels are only attr, boolean, ARIA, class, or text now compile to__adoptScalarBindingsinstead of always pulling in__adoptBindings. The compiler’sscalarAdopter(plan)keeps the general adopter when the plan has styles, projections, host handoff, addressed topology, or richer channel kinds (e.g. URL).The new adopter reuses the same claims, signal connections, transition preview/commit, and dispose/abort behavior, but drops projection, controls, class groups, style restoration, and URL sanitization from adopt-only bundles—~41% smaller gzip on documented scalar examples.
normalizeFixedScalar/writeFixedScalar/resolveFixedNodescentralize scalar DOM writes; the general adopter delegates to them unchanged.__adoptScalarBindingsthrows if a descriptor needs capabilities it does not implement, so misuse cannot skip sanitization. Tests add scalar parity vs the general adopter, bundle boundary checks (size + DOM traces), and handoff coverage for style-free fixtures;verify-distrequires the new export.Reviewed by Cursor Bugbot for commit f9c9ff3. Bugbot is set up for automated code reviews on this repo. Configure here.