Skip to content

removeHiddenElems removes <symbol> which contains children with IDs #1924

@johnkenny54

Description

@johnkenny54

If the <symbol> itself does not have an ID, removeHiddenElems removes <symbol>elements which contains children with IDs.

To Reproduce
Optimize the following with removeHiddenElems enabled:

<svg xmlns="http://www.w3.org/2000/svg">
    <rect fill="url(#a)" width="64" height="64"/>
    <symbol>
        <linearGradient id="a">
            <stop offset="5%" stop-color="gold" />
        </linearGradient>
    </symbol>
</svg>

Expected behavior
File is unchanged because linearGradient is referenced.

Additional context
This bug is part of the cause of test-regression failures on media-flash.svg.

  • SVGO Version 3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions