svg/svgo

removeUselessDefs removes <symbol> which contains children with IDs

johnkenny54 opened this issue · 0 comments

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

To Reproduce
Optimize the following with removeUselessDefs 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