Issue #3343Opened March 17, 2021by neilkyoung0 reactions

BUG: Illegal Invocation error when using keepEmptyTextNodes

Question

Version: 0.16.44

Are you able to reproduce the bug from the demo?

  • Yes
  • No

Set editor.Parser.getConfig().keepEmptyTextNodes = true; in the console and then attempt to drag a form into a 2 column plugin.

What is the expected behavior?

Describe the bug detailed From my observation a keepEmptyTextNodes will throw an error with Sorter.js when a droppable attribute is defined. When it tries to figure out validity it ends up getting the actual text node ahead of the content which means that the matches comparison fails (text node doesn't support matches).

What is the current behavior? Problem area seems to be the below in Sorter.js

        const tempModel = comps.add(dropContent, { ...opts, temporary: 1 });
        dropModel = comps.remove(tempModel, opts);
        dropModel = dropModel instanceof Array ? dropModel[0] : dropModel;
        this.dropModel = dropModel;

This is due to the tempModel then having the text nodes that may wrap the content defined in the block. When it is removed to obtain the dropModel we end up with the text node and not the actual content because of the parsing options.

Describe the bug detailed Attempt to drop plugin 2 into plugin 1 and note an illegal invocation error in the console.

https://codepen.io/neilkyoung/pen/abBxqmY

Are you able to attach screenshots, screencasts or a live demo?

  • Yes
  • No

https://codepen.io/neilkyoung/pen/abBxqmY

https://user-images.githubusercontent.com/3243711/111464171-5762f500-8718-11eb-9765-11d394c2c581.mp4

Answers (3)

artfMarch 23, 20210 reactions

Well, yeah makes sense, probably we should take the first "valid" element (the one which actually supports matches). But I'm also curious to know your case for the use of keepEmptyTextNodes. A few days ago I was actually thinking about removing it 😂

neilkyoungMarch 23, 20210 reactions

@artf A system we use for web page authoring implements this. Although we have now managed to convince them to disable this thanks to your comment above :-D

artfMarch 24, 20210 reactions

Great, I'll close this then. Let me know in case there is something wrong/different with that change on your side

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.