Fixed error, cannot read properties of undefined reading .nodeType#175
Fixed error, cannot read properties of undefined reading .nodeType#175nanov94 wants to merge 1 commit intoProseMirror:masterfrom
Conversation
|
The only way this seems to be possible is if |
|
Hi @marijnh :) Summary:We are encountering an error (below) when selecting table cells, particularly when the table contains empty rows. More details:Yes, you are correct about the case where Why is this the case? Empty rows without table cells:
Secondly, this happened after using another ProseMirror library: prosemirror-tables. |
The line already contains |
Yep, @marijnh, you are right, sorry for confusing 🙏 We catch error when |
|
What version of prosemirror-view are you using? In anything older than 1.31.0 there might be a situation where this happens, on Chrome when the document contains an |
|
we use "prosemirror-view": "1.33.5", |
|
In that case, I'd really want to see instructions on how to reproduce this error, so that I can figure out what the underlying issue is. |
|
We are also seeing this error in Refect Notes (reflect.app). I'm sorry I don't know how to reproduce it though. We're just seeing it in our error logs. |
|
This is what GPT5 is saying:
The problematic spot is here: let prev
// When clicking above the right side of an uneditable node, Chrome will report a cursor position after that node.
if (browser.webkit && offset && node.nodeType == 1 && (prev = node.childNodes[offset - 1]).nodeType == 1 &&
(prev as HTMLElement).contentEditable == "false" && (prev as HTMLElement).getBoundingClientRect().top >= coords.top)
offset--
// Suspiciously specific kludge to work around caret*FromPoint
// never returning a position at the end of the document
if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild!.nodeType == 1 &&Two minimal fixes (either is fine; you can also do both):
Note there’s a second potential out-of-bounds read a few lines below: else if (offset == 0 || node.nodeType != 1 || node.childNodes[offset - 1].nodeName != "BR")Clamping
|

What?
Get error:
TypeError: Cannot read properties of undefined (reading 'nodeType')Why?
In some cases
nodedoes not have children and as a result we get propertynodeTypefromundefinedHow?
Checked existing of
prev