Conversation
Spread children arrays into the returned DOMOutputSpec so sibling elements are spread as separate children instead of nested arrays. Treat a single DOMOutputSpec array (starts with a string) as a single child, filter out null/undefined entries, and treat empty arrays as no children. Add unit tests covering nested siblings and edge cases, and include a changeset.
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🦋 Changeset detectedLatest commit: 3a1adf5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 72 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the JSX runtime where nested sibling elements were not properly rendered, causing ProseMirror's "Invalid array passed to renderSpec" error. The fix modifies the h function to correctly spread children arrays into the DOMOutputSpec structure.
Changes:
- Enhanced JSX runtime to detect and handle multiple sibling children by spreading them into the parent's DOMOutputSpec
- Added comprehensive test suite with 27 tests covering various JSX rendering scenarios
- Created changeset documenting the bug fix
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/core/src/jsx-runtime.ts | Modified h function to properly spread children arrays, distinguishing between single DOMOutputSpecArray children and arrays of multiple children |
| packages/core/tests/jsx-runtime.spec.ts | Added comprehensive test suite covering basic functionality, single/multiple children, edge cases, fragments, slots, and real-world scenarios |
| .changeset/fix-jsx-runtime-nested-siblings.md | Added changeset documenting the patch-level bug fix for nested sibling rendering |
Add tests covering DOMOutputSpec edge cases: tag+0, tag+attrs+0, array of DOMOutputSpec arrays, and nested child DOMOutputSpec. Update h() detection to treat the second element as valid when it is undefined, 0, an attrs object, or a nested DOMOutputSpecArray.
@tiptap/extension-character-count
@tiptap/extension-dropcursor
@tiptap/extension-focus
@tiptap/extension-history
@tiptap/extension-gapcursor
@tiptap/extension-list-item
@tiptap/extension-list-keymap
@tiptap/extension-placeholder
@tiptap/extension-table-cell
@tiptap/extension-table-header
@tiptap/extension-table-row
@tiptap/extension-task-item
@tiptap/extension-task-list
@tiptap/core
@tiptap/extension-audio
@tiptap/extension-blockquote
@tiptap/extension-bubble-menu
@tiptap/extension-bold
@tiptap/extension-bullet-list
@tiptap/extension-code
@tiptap/extension-code-block
@tiptap/extension-code-block-lowlight
@tiptap/extension-collaboration
@tiptap/extension-collaboration-caret
@tiptap/extension-color
@tiptap/extension-document
@tiptap/extension-details
@tiptap/extension-drag-handle
@tiptap/extension-drag-handle-react
@tiptap/extension-drag-handle-vue-2
@tiptap/extension-drag-handle-vue-3
@tiptap/extension-emoji
@tiptap/extension-file-handler
@tiptap/extension-floating-menu
@tiptap/extension-font-family
@tiptap/extension-hard-break
@tiptap/extension-heading
@tiptap/extension-highlight
@tiptap/extension-image
@tiptap/extension-horizontal-rule
@tiptap/extension-invisible-characters
@tiptap/extension-italic
@tiptap/extension-link
@tiptap/extension-list
@tiptap/extension-mathematics
@tiptap/extension-mention
@tiptap/extension-node-range
@tiptap/extension-paragraph
@tiptap/extension-ordered-list
@tiptap/extension-strike
@tiptap/extension-subscript
@tiptap/extension-superscript
@tiptap/extension-table
@tiptap/extension-table-of-contents
@tiptap/extension-text
@tiptap/extension-text-align
@tiptap/extension-text-style
@tiptap/extension-twitch
@tiptap/extension-underline
@tiptap/extension-typography
@tiptap/extension-unique-id
@tiptap/extension-youtube
@tiptap/extensions
@tiptap/html
@tiptap/markdown
@tiptap/react
@tiptap/starter-kit
@tiptap/pm
@tiptap/static-renderer
@tiptap/suggestion
@tiptap/vue-3
@tiptap/vue-2
commit: |
Changes Overview
Fixed JSX runtime to properly render nested sibling elements. The JSX
hfunction now correctly spreads children arrays into the DOMOutputSpec structure required by ProseMirror, resolving the "Invalid array passed to renderSpec" error when using multiple sibling elements in custom node rendering.Implementation Approach
Modified the JSX runtime's
hfunction inpackages/core/src/jsx-runtime.tsto:The fix distinguishes between:
[child1, child2]→ spreads into parent['span', {}, 'text']→ keeps as single childTesting Done
Created comprehensive test suite (
packages/core/__tests__/jsx-runtime.spec.ts) with 27 tests covering:All tests pass, including the specific issue scenario:
Verification Steps
pnpm test:unit jsx-runtime.spec.ts- all 27 tests should passpnpm test:unit- all 597 tests should pass (no regressions)Additional Notes
This fix resolves GitHub issue #6949. The implementation maintains full backward compatibility - all existing code continues to work as before, while new code with multiple siblings now works correctly.
The key insight was distinguishing between a single DOMOutputSpecArray child (which always starts with a string tag) and an array of multiple children (which contains multiple DOMOutputSpecArray elements).
Checklist
Related Issues
Fixes #6949