Squire
Squire copied to clipboard
fixContainer produces a tree with invalid content
Steps
- copy the text from this Pen
- paste the text into Squire
- Use Squire's getHTML method; save the resulting DOMString somewhere
- 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.