Svgo: Empty `defs` added

Created on 4 Nov 2019  路  1Comment  路  Source: svg/svgo

I was trying to see if https://github.com/alrra/browser-logos/blob/a1f2645fce1ac1e41c2bca34f3fc4be89a376941/src/edge/edge.svg from (https://github.com/alrra/browser-logos/pull/180) was run through SVGOMG.

When I enabled the option Replace duplicate elements with links, I noticed an empty <defs/> being added. Maybe there should be a sanity check for this?

I believe SVGOMG is using v1.3.0, so bear with me if this is something fixed after 1.3.0.

Most helpful comment

Correct, a simple SVG without any use elements like:

<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
    <text>
        text element
    </text>
</svg>

Now produces

<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
    <defs/>
    <text>
        text element
    </text>
</svg>

and the element is not needed for rendering.

>All comments

Correct, a simple SVG without any use elements like:

<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
    <text>
        text element
    </text>
</svg>

Now produces

<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
    <defs/>
    <text>
        text element
    </text>
</svg>

and the element is not needed for rendering.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onlymega picture onlymega  路  6Comments

SebKay picture SebKay  路  5Comments

bdkjones picture bdkjones  路  3Comments

wuz picture wuz  路  3Comments

pixelass picture pixelass  路  3Comments