Squire icon indicating copy to clipboard operation
Squire copied to clipboard

fixContainer produces a tree with invalid content

Open mossymaker opened this issue 6 years ago • 0 comments

Steps

  1. copy the text from this Pen
  2. paste the text into Squire
  3. Use Squire's getHTML method; save the resulting DOMString somewhere
  4. Use setHTML to restore the DOMString into Squire

Expected: content appears as it did when pasted Actual: content has additional spacing

Notes

The spacing is caused by giving invalid markup to the editor's root element innerHTML. The invalid markup is introduced when fixContainer wraps inline content with a <div>, but without checking whether the wrapper element is a permitted child of the enclosing element (e.g. <div> is not a permitted in a <span>).

When setHTML gives the content to the root element's innerHTML, the browser doesn't create the same tree from when innerHTML was read.

I have a fix for this...brb.

mossymaker avatar Jan 27 '19 18:01 mossymaker