parchment icon indicating copy to clipboard operation
parchment copied to clipboard

TypeError: Cannot read property 'mutations' of undefined

Open antonioribeiro opened this issue 4 years ago • 7 comments

I believe we have traces of this problem happening in a lot of places, and it should be kind of easy to fix, but maybe not really to understand:

https://github.com/quilljs/parchment/issues/14 https://github.com/quilljs/quill/issues/2312 https://github.com/area17/twill/issues/458 https://github.com/quilljs/quill/issues/889

This error is occurring in Quill when the list of nodes are, somehow, problematic.

This is a simple console.log() of blot.domNode:

image

As you can see the error occurs while processing a <br>, on line 121:

image

Because that line is compiled to

if (blot.domNode[Registry.DATA_KEY].mutations == null) ...

But it could be prevented by just:

if (blot.domNode[Registry.DATA_KEY] && blot.domNode[Registry.DATA_KEY].mutations == null) ...

Because what happens is that this particular node doesn't exists, so a mutation property is, of course, undefined.

antonioribeiro avatar Jun 26 '20 15:06 antonioribeiro

Is there any hotfix available?
It's hard to apply the change to the minified Quill code, and don't want to run unminified in production.

monkeyphysics avatar Jan 06 '21 20:01 monkeyphysics

Although using that guard prevents Quill from crashing in this instance, I also noticed that it clears out the toolbar of selected formats and then when I try and delete any text I get a new error... 'leaf.position is not a function'.

ackmanx avatar Jul 06 '21 03:07 ackmanx

This is my barebones example demonstrating the problem: https://codepen.io/ackmanx/pen/xxqzPyy?editors=1111

ackmanx avatar Jul 06 '21 03:07 ackmanx

I got the same issue. Subscribe to this!

nghuuphuoc avatar Apr 13 '22 03:04 nghuuphuoc

Same issue

parthibanloganathan avatar Apr 29 '22 16:04 parthibanloganathan

same issue

wangziweng7890 avatar Nov 09 '23 10:11 wangziweng7890