Skip to content

fix(octane): don't report an empty style attribute an early binding left - #1861

Merged
domgan-oai merged 11 commits into
mainfrom
fix/unset-style-claim-presence
Oct 7, 2026
Merged

domgan-oai merged 11 commits into
mainfrom
fix/unset-style-claim-presence

Conversation

@trueadm

@trueadm trueadm commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Development hydration no longer reports an empty style attribute that an early binding left behind. This builds on #1859, now merged, and needs the budget-only raise #1869 to merge first.

Repro: in a 'use dom bindings' view with style={{ opacity: props.opacity }}, server-render opacity 1. An early binding (adoptBindings) then publishes opacity as unset, and hydrateRoot runs. Development logged:

style: the server rendered "", the client ""

Why

  • HydrationCapability.keepsStyle treats a claimed early-binding declaration as the server's value. The claims loop removes the claimed declaration from the expected style.
  • But removing the binding's only declaration through CSSOM leaves style="" on the element, the same as the renderer's own style writer does.
  • The attribute-presence check hasAttribute('style') !== (expected !== '') then reported that empty attribute. The early binding left it, not the server.
  • React's hydration contract is the reference: keep the server value, and warn only on a real server/client difference. A claimed publication counts as the server's value.

Changes

keepsStyle in packages/octane/src/runtime.ts:

  • A claimed removal sets removed, and the presence check is skipped when it is set.
  • The claims loop now writes every claimed value through setProperty. Per CSSOM, an empty value removes the declaration, so this drops the separate removeProperty branch.
  • The presence check is now !expected && !removed && hasAttribute('style'). It runs only after the server !== expected comparison, so it is equivalent to the old one: a non-empty cssText implies the attribute is present.
  • An empty style="" that the binding did not leave still reports. That is the case where the binding published a declaration and something else removed it.

packages/octane/tests/binding-handoff.test.ts, built on #1859's adoptedStyleView helper:

  • keeps a style the early binding emptied without a report now sits in the main adopted style publication matrix (dev/prod compile × native/ordinary × literal/forwarded), hydrating with opacity 1 and with undefined. Before the fix it failed in all 4 dev/literal cases with the report above. It replaces fix(octane): keep an early binding's whole-style publication through hydration #1859's forwarded-only adopted whole style publication describe and covers more.
  • New describe, adopted style declaration publication (literal, dev/prod × native/ordinary): reports an empty style attribute that the early binding did not leave. It pins the neighbouring behavior. It fails if the exemption is widened to any claimed element (checked with a mutant: !claims in place of !removed). It is literal-only because a forwarded style with the ordinary writer skips the comparison when the client style is unset. That gap predates this change. No it.runIf: pnpm test:markers:check passes.

Size, measured locally on top of #1859 with node benchmarks/bundle-size/run-minimal.mjs. The earlier flag-only formulation measured +16 raw / +9 gzip on hydrate-root.

scenario raw gzip brotli
hydrate-root −14 +5 −18
deferred-hydration −14 +2 −16
hydrate-frame −14 +4 −13

Stacked with #1857's head as well, every row stays within the current budgets: hydrate-root 137,834 / 44,108 against 137,859 / 44,129, and deferred-hydration 221,130 / 69,609 against 221,155 / 69,610. hydrate-frame raw depends on the checkout path, so its CI shard 1/4 number is the reference.

Validation

  • pnpm format:check (not run repo-wide; pnpm format:files:check on the changed files passes)
  • pnpm typecheck (not run repo-wide; pnpm typecheck:files on the changed files passes)
  • pnpm test (not run locally; CI runs it)
  • targeted tests:
    • binding-handoff.test.ts passes in --project octane (94) and --project octane-prod (94).
    • scalar-dom-bindings.test.ts and hydration/document-lifecycle.test.ts pass in --project octane.
    • The new regression test was seen failing before the fix.
  • pnpm sync leaves the tree clean.

Risk / follow-ups

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. Autofix is disabled.


Note

Low Risk
Narrows dev-only hydration mismatch detection for early style bindings; production hydration behavior is unchanged and behavior is covered by targeted tests.

Overview
Development hydration no longer logs a spurious style mismatch when an early binding (adoptBindings) cleared its only style declaration and left style="" on the element.

keepsStyle now tracks when a claimed style:* declaration was removed via CSSOM and skips the empty-attribute presence check in that case, while still warning if style="" remains but the early binding did not create it. Claimed values are applied uniformly through setProperty (empty values drop the declaration).

Tests in binding-handoff.test.ts cover hydrating after the binding empties the style (no dev warning) and the case where something else removed the binding’s declaration (dev still warns). A patch changeset documents the fix.

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

trueadm and others added 7 commits October 7, 2026 20:18
A module that imports octane/signals compiles every non-literal style, such as
a forwarded style={props.style}, to nativeStyleBinding, because the value might
carry signal handles. The binding then allocated and rendered a control-flow
Block even for undefined, null or a string, which carry no native read. A
production audit of a signed-out home page found 273 such Blocks in one
hydration (about 8 ms at 4x CPU throttling).

Any non-object value now takes the existing scalar writer while the binding has
no Block, whatever the compiler's literal flag. Presentation hydration prepares
the same plain style takeover write without a Block or read witness. The
existing upgrade still allocates the Block, seeded with the last applied style,
once a structured value arrives; the Block then stays, so a later unset style
releases its subscriptions through its own transactional render.

hydrateClaimedBindingCaches dereferenced binding.block for every native style
claim. A Block-less scalar style literal in a signal-enabled binding view made
hydration throw, so the host was rebuilt on the client; it now updates the
binding's own cache.

nativeProjectionBinding is unchanged: the compiler emits it only for
projections that syntactically read handles, so its Block owns real reads.

The signal-dom-bindings bench gains a forwarded-style lane with ratio guards:
style Blocks 2 -> 0 and native style bodies 200 -> 0 per 100 updates.

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

An early binding that owned a whole style (`style={props.style}`, a
`styleObject` channel) never recorded a claim for hydration. Development
therefore reported its publication as a mismatch, and hydration cached the
skipped write as applied: after the binding was released, a render back to the
hydration-time style did not write it, so the early value stayed on screen.

The fixed-layout adopter now publishes a whole style's canonical CSS text, and
keepsStyle treats a matching whole-style claim as the server's value, as it
already did for single declarations. hydrateClaimedBindingCaches already
invalidates the renderer's cache for a claimed `style` channel.

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

# Conflicts:
#	packages/octane/tests/binding-handoff.test.ts
The repository's test-marker check forbids `it.runIf`. The emptied-publication
case applies only to a whole style, so it now has its own describe over
dev/prod and signals-free/signals-enabled views. The view, props and early
adoption helpers it shares with the main matrix are hoisted into
`adoptedStyleView`, so every registered test runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When an early binding publishes a single style declaration as unset before
hydration, removing that declaration can leave `style=""` on the element.
keepsStyle removed the claimed declaration from the expected style, but its
attribute-presence check still reported the empty attribute in development
("the server rendered "", the client """).

A claimed removal now also exempts the attribute's presence. The claims loop
writes the claimed value through setProperty, since an empty value removes the
declaration, and the presence check reduces to "nothing expected, nothing
removed, and an attribute is present", which is equivalent given the cssText
comparison before it. Net -14 raw bytes on hydrate-root, deferred-hydration
and hydrate-frame.

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 fix PR: bug fix labels Oct 7, 2026
@trueadm
trueadm marked this pull request as ready for review October 7, 2026 20:30
…nto fix/unset-style-claim-presence

# Conflicts:
#	packages/octane/tests/binding-handoff.test.ts
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • ❌ bundle-reachability: 1 value(s) exceed their committed budget
  • 🔴 bundle-size: 2 value(s) increased within budget
  • 🔴 bundle-reachability: 5 value(s) increased within budget

Compares 43b60d94f, the merge commit's first parent with 562635821 on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. 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 5.408 5.167 −2.9% −22.0% … +20.5% ⚪ within noise
octane-tsrx replace 14.200 15.258 +4.0% −6.6% … +19.9% ⚪ within noise
octane-tsrx add 4.617 4.275 +2.2% −16.7% … +17.7% ⚪ within noise
octane-tsrx update 0.198 0.206 +3.2% +0.6% … +11.7% ⚪ within noise
octane-tsrx select 0.008 0.008 +0.9% −3.7% … +4.8% ⚪ within noise
octane-tsrx swap 0.036 0.038 +3.3% −4.1% … +8.1% ⚪ within noise
octane-tsrx remove 0.029 0.030 +1.4% −5.9% … +13.3% ⚪ within noise
octane-tsrx runlots 28.750 30.058 +0.1% −3.2% … +8.8% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 −0.3% −1.1% … +0.4% ⚪ within noise
octane-tsrx clear 51.025 49.575 −0.1% −3.6% … +2.3% ⚪ within noise
octane-jsx run 3.542 3.483 −4.7% −5.7% … ±0.0% ⚪ within noise
octane-jsx replace 7.475 8.683 −0.0% −4.5% … +5.3% ⚪ within noise
octane-jsx add 3.367 3.258 −0.0% −3.0% … +3.0% ⚪ within noise
octane-jsx update 0.290 0.276 −3.0% −6.5% … −0.3% ⚪ within noise
octane-jsx select 0.140 0.143 +3.1% +0.5% … +6.6% ⚪ within noise
octane-jsx swap 0.227 0.224 +0.9% −0.6% … +4.8% ⚪ within noise
octane-jsx remove 0.196 0.190 −4.3% −8.3% … +3.1% ⚪ within noise
octane-jsx runlots 31.992 33.517 +1.8% −2.1% … +8.5% ⚪ within noise
octane-jsx select_lots 1.993 2.139 +2.0% −5.6% … +13.9% ⚪ within noise
octane-jsx clear 78.858 80.442 −1.0% −12.1% … +9.4% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx full_fw_raw 564,911 564,897 −14 (−0.0%) 🟢
octane-tsrx full_fw_brotli 142,967 143,066 +99 (+0.1%) 🔴
octane-jsx full_fw_raw 564,911 564,897 −14 (−0.0%) 🟢
octane-jsx full_fw_brotli 142,967 143,066 +99 (+0.1%) 🔴

56 other measured values are unchanged.

Public-import reachability bundles (bytes)

❌ 1 value(s) exceed their committed budget. Reduce the growth, or raise the budget in a separate pull request that names the bytes and the reason (CONTRIBUTING.md, "Size budgets").

target metric head budget over
deferred-hydration gzip 69,612 69,610 +2
target metric base head Δ
hydrate-root raw 137,848 137,834 −14 (−0.0%) 🟢
hydrate-root gzip 44,104 44,108 +4 (+0.0%) 🔴
hydrate-root brotli 38,582 38,620 +38 (+0.1%) 🔴
deferred-hydration raw 221,144 221,130 −14 (−0.0%) 🟢
deferred-hydration gzip 69,610 69,612 +2 (+0.0%) 🔴
deferred-hydration brotli 60,040 60,045 +5 (+0.0%) 🔴
hydrate-frame raw 366,329 366,315 −14 (−0.0%) 🟢
hydrate-frame gzip 113,382 113,385 +3 (+0.0%) 🔴
hydrate-frame brotli 96,884 96,970 +86 (+0.1%) 🔴

102 other measured values are unchanged.

…-presence

# Conflicts:
#	packages/octane/src/runtime.ts
#	packages/octane/tests/binding-handoff.test.ts
domgan-oai pushed a commit that referenced this pull request Oct 7, 2026
…1869)

Budget-only raise, landing ahead of #1861 per CONTRIBUTING "Size budgets".

main 43b60d9 measures deferred-hydration at exactly its 69,610 gzip budget
(#1857 and #1859 filled the headroom). #1861 stops development hydration
reporting an empty style attribute that an early binding left behind, and
measures 69,612 gzip there (-14 raw, +2 gzip). 69,642 is main's measured + 32,
the highest value the ratchet accepts against main, so no other pull request
fails the ratchet while #1861 is open.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@domgan-oai
domgan-oai merged commit 79ca088 into main Oct 7, 2026
21 of 27 checks passed
@domgan-oai
domgan-oai deleted the fix/unset-style-claim-presence branch October 7, 2026 22:12
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.

2 participants