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

removeHiddenElems removes symbols that might be used in another svg on the same page #2084

Open
devongovett opened this issue Nov 4, 2024 · 0 comments
Labels

Comments

@devongovett
Copy link
Contributor

Describe the bug

We have the following test case in Parcel:

<!DOCTYPE html>
<svg>
  <symbol id="all">
    <rect width="100" height="100" x="0" y="0"/>
  </symbol>
</svg>
<svg>
  <use xlink:href="#all" href="#all"/>
</svg>

Each SVG is run through svgo separately. Since svgo 3.1.0, the removeHiddenElems removes the symbol element because it is not referenced. However, it is referenced by a different SVG that will be minified separately.

There should be an option to disable this behavior, specifically when multiple SVGs will be embedded on the same page. You can disable the entire removeHiddenElems plugin, but this also disables lots of other behavior such as removing invisible elements. It would be nice to have a more granular option.

Desktop (please complete the following information):

  • SVGO Version 3.3.2
  • NodeJs Version 20
  • OS: N/A
@devongovett devongovett added the bug label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant