Skip to content

Render dynamic host-tag strings through componentSlot (client + SSR +… - #19

Merged
trueadm merged 1 commit into
mainfrom
claude/objective-matsumoto-7d0f2c
Jul 5, 2026
Merged

trueadm merged 1 commit into
mainfrom
claude/objective-matsumoto-7d0f2c

Conversation

@trueadm

@trueadm trueadm commented Jul 5, 2026 •

Copy link
Copy Markdown
Collaborator

… hydration)

A template-position JSX tag that resolves to a host tag STRING at runtime (<props.parts.title> with { parts: { title: 'h1' } }, with const Tag = 'h1') lowers to componentSlot, which created a 'dynamic' block whose body was the string — renderBlock's block.body(...) then threw "not a function" on both fresh mounts and hydration. The server's ssrComponent likewise tried to invoke the string.

Client: componentSlot now routes a string comp through the existing de-opt host renderer — body = hostElementBody, props = a host ElementDescriptor carrying the tag + props + the compiled children render-fn — so prop diffing, delegated events, commit-phase refs, and hydration adoption all come from the proven machinery. Identity still compares the raw string: same tag patches the element in place; a tag change or string<->function flip tears down and remounts (React's element-type reset). The transition off-screen (WIP) paths are rerouted too so they can't invoke the string.

Server: ssrComponent serializes a string comp as

...children block... via ssrBlock(ssrHostElement), the exact shape the client's componentSlot + hostElementBody adopt on hydration (VALID_TAG_NAME still rejects injection-unsafe tags).

Tests: client mount/update/hydration (hydration/host-string-tag-hydrate), SSR shapes (ssr-host-string-tags), and a differential fixture proving byte-equal HTML vs real React across mount, in-place bumps, and tag flips.


Note

Medium Risk
Touches core componentSlot and ssrComponent reconciliation/hydration paths, but the change is a narrow branch for string comps reusing existing host machinery; value-position behavior is unchanged.

Overview
Template-position JSX whose tag is a runtime host string (<Tag/> with Tag = 'h1', <props.parts.title>, etc.) no longer crashes: componentSlot / ssrComponent used to treat the tag string as a component body and fail with "not a function".

Client: When comp is a string, componentSlot routes through the existing de-opt host path (hostElementBody + an ElementDescriptor), including WIP/off-screen transition renders. Slot identity still uses the raw tag string—same tag patches in place; tag change or string ↔ component remounts like React.

Server: ssrComponent serializes string comps as <!--[--><tag>…children…</tag><!--]--> via ssrHostElement, matching what hydration adopts.

Tests: Hydration, SSR markup, and React differential coverage for mount, updates, tag flips, refs/events, and nested component children.

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

… hydration)

A template-position JSX tag that resolves to a host tag STRING at runtime
(<props.parts.title> with { parts: { title: 'h1' } }, <Tag/> with
const Tag = 'h1') lowers to componentSlot, which created a 'dynamic' block
whose body was the string — renderBlock's block.body(...) then threw
"not a function" on both fresh mounts and hydration. The server's
ssrComponent likewise tried to invoke the string.

Client: componentSlot now routes a string comp through the existing de-opt
host renderer — body = hostElementBody, props = a host ElementDescriptor
carrying the tag + props + the compiled children render-fn — so prop
diffing, delegated events, commit-phase refs, and hydration adoption all
come from the proven machinery. Identity still compares the raw string:
same tag patches the element in place; a tag change or string<->function
flip tears down and remounts (React's element-type reset). The transition
off-screen (WIP) paths are rerouted too so they can't invoke the string.

Server: ssrComponent serializes a string comp as
<!--[--><tag>...children block...</tag><!--]--> via ssrBlock(ssrHostElement),
the exact shape the client's componentSlot + hostElementBody adopt on
hydration (VALID_TAG_NAME still rejects injection-unsafe tags).

Tests: client mount/update/hydration (hydration/host-string-tag-hydrate),
SSR shapes (ssr-host-string-tags), and a differential fixture proving
byte-equal HTML vs real React across mount, in-place bumps, and tag flips.

Co-Authored-By: Claude Fable 5 <[email protected]>
@trueadm
trueadm merged commit 62c3c4e into main Jul 5, 2026
5 checks passed
@trueadm
trueadm deleted the claude/objective-matsumoto-7d0f2c branch July 5, 2026 22:56
trueadm added a commit that referenced this pull request Jul 6, 2026
Merges origin/claude/serene-lehmann-99e802 (PR #18): ssrComponent's string
branch now inlines a template call site's __schildren$N render-fn output as
the element's PLAIN content (rawInner in ssrHostElement) — one outer
<!--[-->…<!--]--> block around the element, no nested block around its
content — per review feedback on #18 flagging the nested-block shape (which
main got via #19) as a bug. Also brings #18's MDX cleanup: the server-mode
_components.* value-hole workaround is dropped now that the runtime handles
string tags natively (merge keeps main's #17 _createMdxContent handling).

Client reworked to match: componentSlot's string branch renders through a
new hostStringTagBody instead of hostElementBody. The element part is the
same de-opt machinery (adopt/create/patch, refs, delegated events, mismatch
recovery), but the compiled children render-fn now renders through ONE
self-bounding Block whose range is all of the element's content — parentNode
= el, no comment markers — so client mounts emit no inner markers and
hydration adopts the server content directly off el.firstChild. A render
prop returning a descriptor still routes through renderBlock's return-slot
(childSlot, block-wrapped), mirroring the server's ssrChild normalization.
Value-position function children (createElement) keep the marker-wrapped
hostElementBody/childSlot path — the server block-wraps those.

Tests unified from both branches: #18's value-position SSR/hydration suite +
this branch's template-position mount/update/hydration suite, all pinned to
the inline shape, plus new template-position SSR pins (component child stays
block-wrapped inside inline content; void; event/ref filtering).

Co-Authored-By: Claude Fable 5 <[email protected]>
trueadm added a commit that referenced this pull request Jul 6, 2026
Main's #18 squash resolved its conflicts against #19 by keeping the old
nested-children server shape (5e36971's inline revision was dropped in the
resolution — the squash touches only mdx/docs/tests, no runtime). This
branch deliberately keeps the review-approved INLINE shape on both sides
(server rawInner + client hostStringTagBody) and re-pins the merged tests
to it; main's duplicated value-position suite and fixture section from the
squash's own unification are deduped against this branch's versions.

Co-Authored-By: Claude Fable 5 <[email protected]>
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.

1 participant