Repository navigation
fix(compilers): textarea value fold must not reserve a hydration id (#3691) - #3696
Conversation
…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 detectedLatest commit: 9201486 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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 |
Merging this PR will not alter performance
Comparing Footnotes
|
…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]>
Coverage Report for CI Build 36453623044Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Warning No base build found for commit Coverage: 73.772%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
Fixes #3691.
Root cause
The SSR transform folds a
<textarea>'svalue/defaultValueinto 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_$scopehydration-id reservation:The client compiles the same JSX to a plain property effect — transparent owner, no id:
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/textContentredirects), which already flags those holes as opaque content that never reserves an id. The textarea fold lives in a different place (transformSpecialCaseAttributesin Babel,special_case_stateful_plans→children_replacementin the native compiler) and never got the flag.Fix
shared/utils.ts): the folded expression container is flagged_childProperty, whichtransformChildrenalready honors to skip the_$scopewrap.ssr/transform.rs):append_childrenskips the reservation when the child is achildren_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
attributeExpressionstemplate99):value={text()},defaultValue={initial()}, followed by a component — both compilers' outputs updated.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 leavestest0) and passes post-fix with bothJSX_COMPILER=babeland native (_hk=1).cargo test, web server harness 96/96, hydrate parity 139/139.Public API changes
None.
Size
Compiler-only change; no runtime bytes.