Skip to content

SSR: render member/dynamic tags resolving to host tag strings - #18

Merged
trueadm merged 3 commits into
mainfrom
claude/serene-lehmann-99e802
Jul 6, 2026
Merged

trueadm merged 3 commits into
mainfrom
claude/serene-lehmann-99e802

Conversation

@trueadm

@trueadm trueadm commented Jul 5, 2026 •

Copy link
Copy Markdown
Collaborator

A member-expression or dynamic JSX tag (<obj.tag/>, <{expr}/>) whose runtime value is a host tag STRING (e.g. MDX's _components.h1 mapping, unoverridden) rendered fine on the client — value-lowered to a createElement descriptor the de-opt renderer accepts — but crashed SSR: the server lowering emits ssrComponent(__s, obj.tag, …), which CALLED the string ("comp is not a function").

ssrComponent now routes a string comp to ssrHostElement inside the same single … block a component body gets (ssrChild's host-descriptor shape), so hydration adopts one uniform range whichever kind the tag resolves to. Dispatch stays dynamic (a function override still renders as a component) and injection-unsafe tag strings still throw, matching the client where document.createElement rejects them.

With the gap closed, drop @octanejs/mdx's SERVER-mode workaround that wrapped _components.* elements in expression containers to force the ssrChild value-hole path (recmaOctaneAdapter adaptation 3).


Note

Medium Risk
Touches MDX compile output and SSR/hydration paths for dynamic tags; behavior change is intentional but affects all server-compiled MDX markdown elements.

Overview
With octane now rendering member/dynamic tags that resolve to host tag strings on SSR (and hydrating them), @octanejs/mdx's recmaOctaneAdapter is trimmed to a single fix: rewriting bare _createMdxContent(props) calls to <_createMdxContent {...props}/> for the component ABI.

Removed server-only ESTree hacks that wrapped <_components.*> in expression containers and the earlier _createMdxContent rename; docs now mark those octane gaps as fixed.

Added octane tests for the MDX-shaped value-position case (<_components.h1>-style member tags in .tsx returns): SSR static/string output, runtime string-vs-component dispatch, and hydrateRoot parity for Doc / Overridable fixtures.

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

A member-expression or dynamic JSX tag (<obj.tag/>, <{expr}/>) whose
runtime value is a host tag STRING (e.g. MDX's _components.h1 mapping,
unoverridden) rendered fine on the client — value-lowered to a
createElement descriptor the de-opt renderer accepts — but crashed SSR:
the server lowering emits ssrComponent(__s, obj.tag, …), which CALLED
the string ("comp is not a function").

ssrComponent now routes a string comp to ssrHostElement inside the same
single <!--[-->…<!--]--> block a component body gets (ssrChild's
host-descriptor shape), so hydration adopts one uniform range whichever
kind the tag resolves to. Dispatch stays dynamic (a function override
still renders as a component) and injection-unsafe tag strings still
throw, matching the client where document.createElement rejects them.

With the gap closed, drop @octanejs/mdx's SERVER-mode workaround that
wrapped _components.* elements in expression containers to force the
ssrChild value-hole path (recmaOctaneAdapter adaptation 3).

Co-Authored-By: Claude Fable 5 <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 95b8c03. Configure here.

Comment thread packages/octane/src/runtime.server.ts Resolved
trueadm and others added 2 commits July 6, 2026 00:01
Review follow-up (Bugbot): a template (@{}) call site compiles a
member/dynamic tag's children to a __schildren$N render fn in
props.children. The string branch passed it into ssrHostElement, whose
descriptor-content path rendered it as a nested COMPONENT body —
wrong calling convention (fresh scope/frame instead of the
ssrChildrenHtml/ProviderBody `(undefined, scope)` convention) and a
stray <!--[-->…<!--]--> around the element's content versus the
value-position / client de-opt shape.

ssrComponent's string branch now calls a function-valued children
directly and inlines its HTML as the element's plain content (holes
inside keep their own blocks, exactly like a static host tag). A
non-compiled fn (a render-prop child) returns a descriptor, not HTML —
normalized via ssrChild, mirroring renderComponentFramed's de-opt
return handling.

Co-Authored-By: Claude Fable 5 <[email protected]>
…-99e802

# Conflicts:
#	packages/mdx/src/compile.ts
#	packages/octane/src/runtime.server.ts
#	packages/octane/tests/hydration/_fixtures/host-string-tag.tsrx
#	packages/octane/tests/hydration/host-string-tag-hydrate.test.ts
#	packages/octane/tests/ssr-host-string-tags.test.ts
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
trueadm merged commit 7aa25cd into main Jul 6, 2026
5 checks passed
@trueadm
trueadm deleted the claude/serene-lehmann-99e802 branch July 6, 2026 06:40
trueadm added a commit that referenced this pull request Jul 6, 2026
…licts

Both conflicts were doc text where this branch's Phase-1 version supersedes
main's intermediate one; kept ours and grafted in main's test-file citations
for gaps 1 and 2.

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