Skip to content

fix(react): prevent crash when ReactNodeViewRenderer returns early#7670

Open
cyphercodes wants to merge 1 commit intoueberdosis:mainfrom
cyphercodes:main
Open

fix(react): prevent crash when ReactNodeViewRenderer returns early#7670
cyphercodes wants to merge 1 commit intoueberdosis:mainfrom
cyphercodes:main

Conversation

@cyphercodes
Copy link
Copy Markdown

Problem

When a custom atom node uses ReactNodeViewRenderer and exists in the initial document at parse time, the renderer could return an empty object if contentComponent wasn't available yet. This caused ProseMirror to crash with:

TypeError: dom.hasAttribute is not a function

This happens because ProseMirror expects a valid NodeView with a dom property, but received an empty object.

Solution

Return a minimal valid NodeView with a placeholder DOM element instead of an empty object when contentComponent is not available. The placeholder NodeView implements all required methods with safe defaults.

Fixes #7641

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 29, 2026

🦋 Changeset detected

Latest commit: d4a57cb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 72 packages
Name Type
@tiptap/react Patch
@tiptap/extension-drag-handle-react Patch
@tiptap/core Patch
@tiptap/extension-audio Patch
@tiptap/extension-blockquote Patch
@tiptap/extension-bold Patch
@tiptap/extension-bubble-menu Patch
@tiptap/extension-bullet-list Patch
@tiptap/extension-code-block-lowlight Patch
@tiptap/extension-code-block Patch
@tiptap/extension-code Patch
@tiptap/extension-collaboration-caret Patch
@tiptap/extension-collaboration Patch
@tiptap/extension-color Patch
@tiptap/extension-details Patch
@tiptap/extension-document Patch
@tiptap/extension-drag-handle-vue-2 Patch
@tiptap/extension-drag-handle-vue-3 Patch
@tiptap/extension-drag-handle Patch
@tiptap/extension-emoji Patch
@tiptap/extension-file-handler Patch
@tiptap/extension-floating-menu Patch
@tiptap/extension-font-family Patch
@tiptap/extension-hard-break Patch
@tiptap/extension-heading Patch
@tiptap/extension-highlight Patch
@tiptap/extension-horizontal-rule Patch
@tiptap/extension-image Patch
@tiptap/extension-invisible-characters Patch
@tiptap/extension-italic Patch
@tiptap/extension-link Patch
@tiptap/extension-list Patch
@tiptap/extension-mathematics Patch
@tiptap/extension-mention Patch
@tiptap/extension-node-range Patch
@tiptap/extension-ordered-list Patch
@tiptap/extension-paragraph Patch
@tiptap/extension-strike Patch
@tiptap/extension-subscript Patch
@tiptap/extension-superscript Patch
@tiptap/extension-table-of-contents Patch
@tiptap/extension-table Patch
@tiptap/extension-text-align Patch
@tiptap/extension-text-style Patch
@tiptap/extension-text Patch
@tiptap/extension-twitch Patch
@tiptap/extension-typography Patch
@tiptap/extension-underline Patch
@tiptap/extension-unique-id Patch
@tiptap/extension-youtube Patch
@tiptap/extensions Patch
@tiptap/html Patch
@tiptap/markdown Patch
@tiptap/pm Patch
@tiptap/starter-kit Patch
@tiptap/static-renderer Patch
@tiptap/suggestion Patch
@tiptap/vue-2 Patch
@tiptap/vue-3 Patch
@tiptap/extension-character-count Patch
@tiptap/extension-dropcursor Patch
@tiptap/extension-focus Patch
@tiptap/extension-gapcursor Patch
@tiptap/extension-history Patch
@tiptap/extension-list-item Patch
@tiptap/extension-list-keymap Patch
@tiptap/extension-placeholder Patch
@tiptap/extension-table-cell Patch
@tiptap/extension-table-header Patch
@tiptap/extension-table-row Patch
@tiptap/extension-task-item Patch
@tiptap/extension-task-list Patch

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

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 29, 2026

Deploy Preview for tiptap-embed failed. Why did it fail? →

Name Link
🔨 Latest commit d4a57cb
🔍 Latest deploy log https://app.netlify.com/projects/tiptap-embed/deploys/69c9a85bf862890008b7f94e

@cyphercodes cyphercodes force-pushed the main branch 2 times, most recently from 9626f09 to 98a3ab7 Compare March 29, 2026 22:29
When contentComponent is not available, return a minimal valid NodeView
with a placeholder DOM element instead of an empty object. This prevents
ProseMirror from crashing with 'dom.hasAttribute is not a function' when
using custom atom nodes with renderHTML returning text in the initial document.

Fixes ueberdosis#7641
"ts-loader": "9.3.1",
"tsup": "^8.5.1",
"turbo": "2.3.3",
"typescript": "^5.7.3",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't mind updating this, but I think we should remove it from this PR and keep it clean and focused on the specific fix, not generic dependency upgrades

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.

ReactNodeViewRenderer crashes when nodes exist in initial document and renderHTML returns text

2 participants