Repository navigation
compiler: classify _/$-prefixed identifier JSX tags as component references - #17
Merged
Merged
Conversation
…rences
JSX semantics (Babel/TS isCompatTag) treat an identifier tag as a host
string tag only when it starts with a lowercase ASCII letter; isComponentTag
used /^[A-Z]/, so <_Inner/> and <$Inner/> miscompiled to host string tags
(client: _$template("<_Inner></_Inner>"), server: literal markup or an
Invalid-tag throw). Host tags remain lowercase-start or dashed identifiers
(<my-element>).
Drop @octanejs/mdx's MDX$CreateMdxContent rename workaround for this gap
(the bare-call-to-JSX rewrite stays — that's the component-ABI concern).
Co-Authored-By: Claude Fable 5 <[email protected]>
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]>
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.
What changed
isComponentTaginpackages/octane/src/compiler/compile.jsclassified an identifier JSX tag as a component only when it matched/^[A-Z]/. JSX semantics (Babel/TypeScript'sisCompatTag, ESTree) say an identifier tag is a host string tag only when it starts with a lowercase ASCII letter — anything else, including_- and$-prefixed identifiers, is a component reference.Before this fix,
<_Inner/>miscompiled in both modes:_$template("<_Inner></_Inner>")— a host template that renders a literal<_inner>element<_Inner>markup (or anInvalid tag: _Innerthrow viassrHostElement'sVALID_TAG_NAMEguard on non-static paths)Now both modes emit a component reference:
_$createElement(_Inner, {})/_$ssrComponent(__s, _Inner, {}). Lowercase and dashed tags (<div>,<my-element>) stay host tags, matching Babel (a dashed tag is not a valid JS identifier, so it can never be a reference).isComponentTagis the single decision point — the client lowering,jsxElementToCreateElement, and the server emitter all route through it. I audited the compiler for other case-based host-vs-component checks and found none (the remaining/^[A-Z]/uses are event-name anduse[A-Z]hook detection).@octanejs/mdx simplification
The gap was found while building the MDX binding: MDX names its body component
_createMdxContent, andrecmaOctaneAdapterrenamed it toMDX$CreateMdxContentpurely to dodge this miscompile. That rename is now dropped. The bare-call→JSX rewrite (_createMdxContent(props)→<_createMdxContent {...props}/>) is kept — that adaptation exists for octane's(props, __s, __extra)component ABI, not for tag classification.Tests
packages/octane/tests/component-tag-names.test.ts:<_Inner/>and<$Inner/>compile as component references in client and server modes; lowercase/dashed tags remain host tags.packages/mdx/tests/compile.test.tsupdated for the dropped rename (asserts the body mounts via_$createElement(_createMdxContent, …)with no direct-call shape).octanepatch).Full
pnpm test(312 files, 2205 passed + 5 pre-existing expected fails),pnpm typecheck, andpnpm format:checkare all green.🤖 Generated with Claude Code
Note
Medium Risk
Touches the central
isComponentTaggate used by client and server codegen, so misclassification could affect any JSX with non-lowercase identifier tags; scope is narrow and covered by new tests.Overview
Octane’s JSX lowering now treats identifier tags as host elements only when the name starts with a lowercase ASCII letter and has no dash—aligned with Babel/TS
isCompatTag. Tags like<_Inner/>and<$Inner/>compile to component references (createElement/ssrComponent) instead of string host tags or broken SSR.@octanejs/mdx drops the
recmaOctaneAdapterrename from_createMdxContenttoMDX$CreateMdxContent; the bare-call→JSX rewrite for the no-layout branch is unchanged for the component ABI.New
component-tag-namestests cover client/server; MDX compile tests expect_createMdxContentin emitted code.Reviewed by Cursor Bugbot for commit 59c57d3. Bugbot is set up for automated code reviews on this repo. Configure here.