This PR modifies SVGO to always preserve white space within <foreignObject> elements. In general there is no way to know the semantics of the <foreignObject> content, so all white space within the element is preserved.
The following changes were made:
parser.js - keeps track of whether the parser is within a <foreignObject> element, and if so does not trim text or comment nodes.
stringifier.js - keeps track of whether the stringifier is within a <foreignObject> element, and if so does not emit prettification indentation or newlines.
_collections.js - removed 'pre' from textElems set - this was added by PR #1796, but is not necessary since all <foreignObject> content now preserves white space.`.
Added a test case to confirm that CDATA and comments are preserved within a <foreignObject>.
Modified expected results in several test files. In all cases, the expected result is now to preserve the contents of the <foreignObject> element exactly.
Thanks for this PR. If all it does is to preserve white space within foreignObject elements, then it does not address #1728. #1728 is about invalid self-closing tags, not preserving whitespace.
This PR modifies SVGO to always preserve white space within
<foreignObject>
elements. In general there is no way to know the semantics of the<foreignObject>
content, so all white space within the element is preserved.The following changes were made:
<foreignObject>
element, and if so does not trim text or comment nodes.<foreignObject>
element, and if so does not emit prettification indentation or newlines.textElems
set - this was added by PR #1796, but is not necessary since all<foreignObject>
content now preserves white space.`.<foreignObject>
.<foreignObject>
element exactly.Resolves #1678, resolves #1473.