Repository navigation
fix(octane): render a textarea's children as one text value on both sides - #1435
Merged
Merged
Conversation
…ides Textarea content is RCDATA: the HTML parser keeps markup and comments inside it as literal text. A textarea with more than one child compiled to a client template with `<!>` placeholders inside the textarea (a client-only mount threw reading `parentNode` of null) and a server frame such as `hello <!-- -->A`, so the pre-hydration value held the markers and hydration reported a mismatch or rebuilt the root. A textarea's children now fold into one text value. The compiler binds it as the host's only Text node through `textareaText` and the server serializes it markerless through `ssrTextareaText`. Descriptor textareas (createElement, stored JSX) and a children prop from a spread follow the same rule. Strings and numbers render, empty values render nothing, arrays and iterables join, and any other value throws error 336 on both sides. Markup or a template directive written inside a textarea is a compile error. Signal handles in a compiled textarea's holes stay live through one derived handle over the parts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The spread textarea default reset is fixed on main (#1432), so the spread cases now join the shared mount, hydrate and update matrix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Uppercase textarea deopt skips text fold
- Replaced raw descriptor type comparisons (d.type/value.type === 'textarea') with el.localName === 'textarea' in both deoptHostChildren and reconcileDeoptNode, since the DOM always lowercases localName regardless of the authored createElement spelling, matching the server's tag.toLowerCase() normalization.
Or push these changes by commenting:
@cursor push b52c93f081
Preview (b52c93f081)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -32083,7 +32083,7 @@
if (!hasHostPropContent(value)) {
reconcileDeoptChildren(
el,
- value.type === 'textarea' && elNs === undefined
+ el.localName === 'textarea' && elNs === undefined
? textareaChildText(value.children, rejectTextareaChild)
: value.children,
ownerBlock,
@@ -32664,7 +32664,7 @@
elNs: string | undefined,
adopt = false,
): void {
- if (d.type !== 'textarea' || elNs !== undefined) {
+ if (el.localName !== 'textarea' || elNs !== undefined) {
childSlot(block, 0, el, d.children, null, false, el);
return;
}You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 24a56e5. Configure here.
trueadm
marked this pull request as ready for review
September 29, 2026 23:03
2 of 5 tasks
HTML tag names are ASCII case-insensitive, and ssrHostElement folds a
descriptor textarea's children on the lowercased tag. The client compared
the authored type exactly, so `createElement('TEXTAREA', null, 'a', list)`
still reconciled its children as a keyed list and left range comments
inside the textarea. Both de-opt paths now share a case-insensitive check
that compares the string before any DOM read.
With main merged, the only-child hole tests from #1430 expected an element
value inside a textarea to render beside the server text. A textarea's
children are text on both sides now, so that case asserts the error on the
server and through onUncaughtError on the client, and the suspending-hole
fixture no longer puts an element in a textarea.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 30, 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
A
<textarea>'s children are now text on both the client and the server. Textarea content is RCDATA: the HTML parser keeps markup and comments inside it as literal text, so no template placeholder or hydration marker can live there.Before this change:
<textarea>hello {v as string}</textarea>threwCannot read properties of null (reading 'parentNode')on a client-only mount. The client template embedded<!>inside the textarea, which the parser turned into text, so the compiled walk found no placeholder.<textarea>hello <!-- -->A</textarea>, so the default value before hydration was literallyhello <!-- -->A, and hydration reported a mismatch.<textarea>hello {v}</textarea>and<textarea>{a}{b}</textarea>mounted with a literal<!>in the value, and hydration rebuilt the textarea.<!--[--><p>x</p><!--]-->as text, the client inserted a real<p>that the value ignores, and hydration abandoned root adoption.Contract
textareaText, and the server serializes it markerless throughssrTextareaText. A leading newline is still doubled for the parser.{x}renders strings and numbers, rendersnull,undefinedand booleans as nothing, and joins arrays or iterables of text.{x as string}stringifies like any text binding (true→"true").@if/@for/@switch/@try, JSX expression or<title>written inside a textarea is a compile error on both emit paths. A textarea in the SVG namespace is unchanged.createElementdescriptors and stored JSX (pure-host and block-backed de-opt paths, plusssrHostElement), and achildrenprop from a spread (childTextHoleandssrChildrenSources). A descriptor's tag matches case-insensitively, socreateElement('TEXTAREA', …)folds on the client exactly as the server's lowercased tag does.textareaTextreturns one derived handle over the parts, so the existing direct text binding subscribes to each signal. A descriptor textarea takes text children only; the raw de-opt reconciler never supported handle children.'' + children, so an element becomes[object Object]andfalsebecomes"false". The divergence is documented indocs/differences-from-react.md.Change to #1430's textarea cases
#1430 (merged while this PR was open) pinned a different textarea outcome in
mismatch-structural.test.ts: an element value in a textarea's hole kept the server text and rendered the element beside it (A<em class="waits">R</em>inside the textarea). That conflicts with this PR's contract, so:onUncaughtErrorwith no recoverable-error reports.<div>hole reporting once and building once, is unchanged.hydrateOnlyChildstays. It is now reached only by a signal handle passed straight tochildTextHole.Validation
pnpm format:files:checkon every changed file (not the repo-widepnpm format:check)pnpm typecheck:fileson the changed TS/TSRX files, withtsrx-tsc(not the repo-widepnpm typecheck)pnpm test: not run in full locally, which runs out of memory here. I ran the relevant Vitest projects instead:octane+octane-prodin full, before the final merge ofmain: 25,313 / 25,313 pass.main: 25,817 / 25,823. The 6 failures all pass when rerun in isolation. Four were 5 s timeouts (hmr.test.ts,independent-island,independent-parent). Two werebehavior-root"(prod)" textarea retirement tests whose root was never created under load; they pass 3 of 3 in isolation. I'm treating these as load flakes, and CI will confirm.textarea-autosize(+differential, +ssr),html-react-parser,hook-form(+server),shadcn(+ssr),aria-ssr,base-ui-ssr,mdxandvite-pluginall pass (1,917 tests).packages/octane/tests/hydration/textarea-children-hydrate.test.ts, which runs in dev and prod. It covers server serialization, hydration adoption with no recoverable errors or reports, updates, client-only mount and update, signal parts, and non-text values throwing on both sides. 100 of its 104 original cases fail on the pre-fix source; the 4 that pass are controls.packages/octane/tests/compiler/compile-errors.test.tsfor markup, components, directives and<title>inside a textarea, plus an SVG-namespace control.spread-sole-child-hydrate,client-host-source-aggregation,folded-head-prefix-hydrate,subtemplate-own-localsandhead-hydrate: all pass.mainwith fix(octane): discard server text an only-child hole's element value cannot adopt #1430 merged):textarea-children-hydrateandmismatch-structuralpass in dev and prod (96 and 316 tests). The new uppercase-tag cases fail with the old exact check.octane+octane-prodrun on a machine at load average 33–44 failed only in unrelated files: 5 s/15 s timeouts, andbehavior-roottextarea-retirement tests whose fixtures usevalueprops with no children. That fixture compiles byte-identically on the client againstmain. On the server it differs only by the newssrChildrenSourcestextarea flag, which is inert without a spreadchildren. The previous head's CI, including all four test shards, was green.pnpm error-codes:checkandpnpm sync. Sync regenerated onlypackages/cli/src/data/octane-data.jsonfor error 336.Bundle size, from
benchmarks/bundle-size/run-minimal.mjson the same machine, baseline against this change:No budget is newly exceeded.
capture-only,hydrate-root,deferred-hydration,suspense-transition,server-renderand apollo were already over budget on the baseline. Routing de-opt textareas through the derived signal handle as well would have cost about another 200 B gzip on every general-runtime app, so the de-opt path takes text only.Risk / follow-ups
childrenprop supplied through a spread still resets to an empty default value on update. That is theapplyFormControlValuesreset: fix(octane): serialize a spread host's sole child unframed and keep textarea children live #1432 fixed it for authored children but not for a spread-heldchildrensource. I filed a separate task; the new test covers that case's serialization and hydration only.createElement('DIV'), is still rebuilt on each client render and on hydration, because the client matcheslocalNameagainst the authored type exactly. This predates the PR and is not textarea-specific; it is filed as a separate task.<Tag>that resolves totextareaat runtime (its children compile as an ordinary children template); authored DOM binding views (dom-binding-program); and a textarea withdangerouslySetInnerHTML, which React rejects anyway.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches compiler emission, client hydration, and SSR for a form-control host where RCDATA semantics must stay aligned; scope is narrow but incorrect behavior would affect every multi-child textarea and createElement paths.
Overview
<textarea>children now fold into a single text default value on the client and server, avoiding hydration markers (<!>,<!-- -->) that HTML treats as literal textarea content and that previously caused mismatches, null-mount crashes, and literal placeholder text in the value.The compiler adds a dedicated multi-child path (
textareaTextParts→ runtimetextareaText/ssrTextareaText) instead of per-child slots with markers.textareaChildTextcentralizes text coercion (strings, numbers, joined arrays/iterables; nullish/booleans empty). Non-text children (elements, functions, objects) throw error 336 at runtime and are compile errors for markup, components, and template directives inside<textarea>(HTML namespace only; SVG unchanged).The same rule applies to
createElement/ stored JSX (deoptHostChildren,ssrHostElement), and to achildrenprop from a spread (ssrChildrenSources,childSlot). Compiled textareas with signal holes get one derived signal handle over the joined parts. Docs and a changeset describe the React divergence (React stringifies a single child with'' + children).Reviewed by Cursor Bugbot for commit 4dc758f. Bugbot is set up for automated code reviews on this repo. Configure here.