Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve all white space within foreignObject elements. #2064

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

johnkenny54
Copy link
Contributor

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 fix: dont trim pre elements #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.

Resolves #1728, resolves #1678, resolves #1473.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant