Skip to content

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

Open
@devongovett

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions