fix(core): guard MarkdownRenderable.getStyle against undefined syntaxStyle#606
Merged
kommander merged 1 commit intoanomalyco:mainfrom Feb 2, 2026
Merged
Conversation
17728ea to
d0d7534
Compare
…Style
The Solid reconciler creates elements with `new Element(ctx, { id })` —
only `id` is passed in constructor options. Props are applied via setters
in JSX declaration order. When `content` is set before `syntaxStyle`,
the content setter triggers `updateBlocks()` → `createChunk()` →
`getStyle()` which accesses `this._syntaxStyle` — still undefined.
This crashes with: `TypeError: undefined is not an object
(evaluating 'this._syntaxStyle.getStyle')`
The guard returns undefined when `_syntaxStyle` hasn't been initialized
yet, producing unstyled text. Once `syntaxStyle` is set via its setter,
`_styleDirty` triggers `rerenderBlocks()` on the next render cycle,
applying correct styles.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
d0d7534 to
3aea717
Compare
@opentui/core
@opentui/react
@opentui/solid
@opentui/core-darwin-arm64
@opentui/core-darwin-x64
@opentui/core-linux-arm64
@opentui/core-linux-x64
@opentui/core-win32-arm64
@opentui/core-win32-x64
commit: |
11 tasks
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
MarkdownRenderable.getStyle()against_syntaxStylebeing undefined when the Solid reconciler setscontentbeforesyntaxStyleProblem
The
@opentui/solidreconciler creates elements withnew Element(ctx, { id })— only{ id }is passed in constructor options. Props are then applied via setters in JSX declaration order.When a consumer writes:
The
contentsetter fires first, triggeringupdateBlocks()→createChunk()→getStyle(), which accessesthis._syntaxStyle— stillundefinedbecause thesyntaxStylesetter hasn't run yet.This crashes with:
Note
There's an existing branch
fix(solid)-prop-initialization-before-insertthat attempts to fix this at the Solid/babel level. This PR takes a complementary approach — defensive guard inMarkdownRenderableitself, so the component is resilient regardless of prop order.Fix
undefinedfromgetStyle()when_syntaxStyleis uninitializedsyntaxStylesetter runs,_styleDirtytriggersrerenderBlocks()on the next render cycle with correct stylesTest plan
<markdown content={...} syntaxStyle={...} />)Markdown.ts)🤖 Generated with Claude Code