Skip to content

fix(octane): serialize a spread host's sole child unframed and keep textarea children live - #1432

Merged
trueadm merged 1 commit into
mainfrom
claude/nifty-colden-f4765a
Sep 29, 2026
Merged

trueadm merged 1 commit into
mainfrom
claude/nifty-colden-f4765a

Conversation

@trueadm

@trueadm trueadm commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Server rendering <textarea {...rest}>{value}</textarea> wrote hydration markers inside the textarea. Textarea content is RCDATA, so the parser kept them as text: before hydration the default value was literally <!--[-->A<!--]-->, and hydrateRoot with identical props reported a text mismatch to onRecoverableError and console.error.

Root cause (compiler). The client lowers a host's only renderable {expr} child markerless (onlyChildText) whether or not the host has a spread. The server's matching branch in ssrEmitElement also required htmlSources.length === 0. Every spread pushes a possible dangerouslySetInnerHTML source, so spread hosts fell back to ssrEmitNodes and a framed ssrChildPre. The client's htext unwraps such a frame on ordinary hosts, which hid the drift everywhere except RCDATA. Dropping the gate makes the server's condition match the client's again. That also fixes:

  • a ternary sole child in a spread textarea (same mismatch);
  • <option {...rest}>{label}</option> without a value. ssrOptionSelected skips its text fallback when content contains <, so a framed label never matched the select's value/defaultValue, and the server painted the wrong option until hydration.

Second defect found while testing (runtime). Updating the child of a spread textarea emptied it, even client-only: mount 'A', render 'Updated', get ''. applyFormControlValues resets a textarea's defaultValue to '' on every non-first update with no value/defaultValue, mirroring React's updateTextarea, where children only seed the initial value. Octane's authored textarea children are a live text binding (docs/differences-from-react.md), so the reset detached the child's Text node. It is now skipped when the host has nested children. setHostPropSources already knows this and threads it through. The formCommit/setFormControlSources path is unreachable for spread hosts, and a childless spread textarea keeps React's reset (the existing conformance test for that still passes).

Validation

  • pnpm format:check (not run repo-wide; pnpm format:files:check on changed files is clean)
  • pnpm typecheck (not run repo-wide; pnpm typecheck:files is clean for the source and new test files. The conformance fixture file already has untyped props and deliberate duplicate-attribute errors on main, and this adds none.)
  • pnpm test (not run in full locally because it runs out of memory)
  • targeted tests:
    • packages/octane/tests in octane + octane-prod before rebase: 1,233 files / 25,216 tests pass
    • after rebasing onto main: tests/hydration, tests/conformance, tests/compiler, tsrx-block.test.ts in both projects: 463 files / 10,745 tests pass
    • octane-signals* projects: 58 files / 991 tests pass
    • binding hydration/SSR suites that reference frames (popper, redux-toolkit, shadcn, sonner, draggable, colorful, waypoint, remix-router ssr-static, dnd-kit, streamdown, cmdk, spring): 13 files pass
    • New tests/hydration/spread-sole-child-hydrate.test.ts (31 cases × dev/prod). It checks that the server-rendered textarea defaultValue is the plain text, that identical-props hydration reports nothing, that the node is reused, and that a later update works; plus the ternary and option cases. With the compiler fix reverted, 22 of 31 fail (e.g. expected '<!--[-->A<!--]-->' to be 'A').
    • New conformance case in client-host-source-aggregation.test.ts fails with the runtime fix reverted (expected '' to be 'second').

No timing benchmark was run. The change removes work: 16 marker bytes per affected host on the server, and the client no longer strips them during hydration. Client code is unchanged apart from one boolean argument on the spread form-host update path.

Risk / follow-ups

  • Server output changes for every spread host with a sole renderable child, not only textareas: primitives and nullish values are now emitted unframed, which is the shape the client already mounts for direct children. Objects, arrays and components still go through ssrChild and keep their frame.
  • Still open, in the same RCDATA family:
    • an element or array as a textarea's sole child (the server's markup becomes text while the client inserts a real element; React coerces to a string);
    • textareas with more than one child (hello {x as string}), which crash client-only because template placeholders land inside RCDATA.
  • A body <title {...rest}>{x}</title> also mismatches on hydration. That is unrelated and reproduces on main.

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

Medium Risk
Changes SSR markup for all spread hosts with a sole primitive child and adjusts textarea form-control updates on the spread path; behavior is intentional but affects hydration-sensitive RCDATA and form defaults.

Overview
Aligns server HTML with how the client already mounts a host’s only renderable {expr} child when the host also has a prop spread. The compiler no longer requires “no raw-HTML sources” before emitting markerless ssrChildText, so spread hosts stop wrapping that child in <!--[-->…<!--]-->. That fixes hydration text mismatches inside <textarea> (RCDATA keeps comments as literal default value) and wrong pre-hydration <select> selection when <option {...rest}>{label}</option> has no value and framed label text could not match defaultValue.

On the client, spread textarea updates no longer wipe authored child text: applyFormControlValues skips React-style defaultValue = '' resets when the textarea has nested authored children, preserving Octane’s live text binding when the spread does not supply value/defaultValue.

Adds hydration coverage for spread/direct/ternary textarea cases and spread options, plus a conformance test for <textarea {...rest}>{child}</textarea> updates.

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

…extarea children live

The client mounts a host's only renderable `{expr}` child markerless whether
or not the host has a spread. The server's only-child branch was additionally
gated on having no dangerouslySetInnerHTML source, and every spread adds one,
so spread hosts fell back to a framed `<!--[-->…<!--]-->` child. Inside a
<textarea> (RCDATA) that frame parsed as literal default-value text and
hydration reported a text mismatch. It also hid an option's label from the
server select projection, so `<option {...rest}>{label}</option>` was never
server-selected.

On the client, `applyFormControlValues` reset a textarea's defaultValue to ''
on every update without value/defaultValue (React's updateTextarea). Authored
Octane textarea children are a live text binding, so that reset detached the
child's Text node and every update emptied a spread textarea. Skip the reset
when the host has nested children.

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 Sep 29, 2026
@github-actions
github-actions Bot marked this pull request as draft September 29, 2026 21:30
@trueadm
trueadm marked this pull request as ready for review September 29, 2026 21:59
@trueadm
trueadm merged commit d7ffa13 into main Sep 29, 2026
33 of 34 checks passed
@trueadm
trueadm deleted the claude/nifty-colden-f4765a branch September 29, 2026 21:59
trueadm added a commit that referenced this pull request Sep 29, 2026
…ides (#1435)

* fix(octane): render a textarea's children as one text value on both sides

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]>

* test(octane): update mixed children of a spread textarea after hydration

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]>

* fix(octane): fold a de-opt textarea's children whatever its tag's case

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]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Sep 30, 2026
…ross updates (#1438)

A textarea's `children` from a spread or a `children=` prop renders through
the same live text binding as authored children, but applyFormControlValues
only knew about authored JSX children (#1432). Every update without a
value/defaultValue writer ran React's updateTextarea reset
(`defaultValue = ''`), which detached the binding's Text node, so later
updates wrote outside the element and the field emptied. This hit
`<textarea {...{ children }} />`, `{...rest} children=`, a direct
`children= value= defaultValue=` cascade, and a signal-held sibling prop that
re-applies host props on its own, both client-only and after hydration.

Skip the reset when a children writer was present at the previous commit,
which is when the child binding can still hold DOM. Keying on the incoming
props instead would append to a removed defaultValue's text when children
take over (`{defaultValue:'Y'} -> {children:'B'}` rendered "YB"); the
previous-commit rule matches the createElement path exactly.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant