Skip to content

fix(compilers): textarea value fold must not reserve a hydration id (#3691) - #3696

Merged
ryansolid merged 2 commits into
nextfrom
fix/textarea-value-hydration-id-3691
Sep 28, 2026
Merged

ryansolid merged 2 commits into
nextfrom
fix/textarea-value-hydration-id-3691

Conversation

@ryansolid

Copy link
Copy Markdown
Member

Fixes #3691.

Root cause

The SSR transform folds a <textarea>'s value / defaultValue into its text content (HTML textareas carry their value as content). That fold hands the value to the child pipeline as an ordinary expression child, and a dynamic expression child takes the _$scope hydration-id reservation:

// server (before)
_v$2 = _$scope(() => _$escape(text())),   // consumes Home's child slot 0
_v$3 = _$escape(Counter({}));             // Counter is slot 1

The client compiles the same JSX to a plain property effect — transparent owner, no id:

// client
_$insert(_el$, _$createComponent(Counter, {}), ...);  // Counter is slot 0
_$effect(() => text(), v => _$setProperty(_el$2, "value", v));

So every keyed sibling after the textarea hydrates one id off. In the reporter's app that's Counter's button: server _hk=…3, client looking for …2, click updates detached DOM.

This is the same shape as #3015 (innerHTML / textContent redirects), which already flags those holes as opaque content that never reserves an id. The textarea fold lives in a different place (transformSpecialCaseAttributes in Babel, special_case_stateful_plans → children_replacement in the native compiler) and never got the flag.

Fix

  • Babel (shared/utils.ts): the folded expression container is flagged _childProperty, which transformChildren already honors to skip the _$scope wrap.
  • Native (ssr/transform.rs): append_children skips the reservation when the child is a children_replacement.

Both now emit () => _$escape(text()) with no scope, matching the client's non-allocating property write. The spread-element path is unaffected (the fold is skipped when a spread is present).

Tests

  • Shared SSR-hydratable fixture (attributeExpressions template99): value={text()}, defaultValue={initial()}, followed by a component — both compilers' outputs updated.
  • Parity-harness scenario textarea-value-id-parity (<textarea value={text()} /><Counter />, click the counter after hydrating). Verified it fails pre-fix with the reporter's exact symptom (server <button _hk=2>, click leaves test0) and passes post-fix with both JSX_COMPILER=babel and native (_hk=1).
  • Full runs: babel-plugin 268/268, compiler 5938/5938 + cargo test, web server harness 96/96, hydrate parity 139/139.

Public API changes

None.

Size

Compiler-only change; no runtime bytes.

…3691)

The SSR textarea value/defaultValue fold turns the attribute into a
dynamic text child, and that child took the `_$scope` hydration-id
reservation a dynamic hole gets. The client writes the value as a plain
property effect that never allocates an id, so every component after the
textarea hydrated one id off and its updates targeted detached DOM.

Treat the fold like the innerHTML/textContent redirects (#3015): opaque
content, no reservation. Babel flags the folded container with
_childProperty; the native compiler skips the reservation for a
children_replacement. Shared fixture + parity-harness scenario added.

Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
@changeset-bot

changeset-bot Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9201486

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@solidjs/babel-plugin Patch
@solidjs/compiler Patch
test-integration Patch
@solidjs/diagnostics Patch
@solidjs/element Patch
@solidjs/h Patch
@solidjs/html Patch
@solidjs/signals Patch
solid-js Patch
@solidjs/universal Patch
@solidjs/web Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codspeed

codspeed Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 180 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing fix/textarea-value-hydration-id-3691 (9201486) with next (656f0df)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

…ea fold flag

The fold's _childProperty cast referenced `babelTypes`, which utils.ts does
not import (it aliases @babel/types as `t`). Rollup's transpile let it
through; the typecheck step did not.

Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 36453623044

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Warning

No base build found for commit ee49b3e on next.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 73.772%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 1183
Covered Lines: 922
Line Coverage: 77.94%
Relevant Branches: 914
Covered Branches: 625
Branch Coverage: 68.38%
Branches in Coverage %: Yes
Coverage Strength: 27.24 hits per line

💛 - Coveralls

@ryansolid
ryansolid merged commit 077c787 into next Sep 28, 2026
7 checks passed
@ryansolid
ryansolid deleted the fix/textarea-value-hydration-id-3691 branch September 30, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants