mirror of
https://github.com/svg/svgo.git
synced 2026-01-25 18:41:39 +03:00
Fixes a bug where we were too eager to remove empty containers. We already had logic to skip removing empty containers if it had the filter attribute, which is needed to apply a filter to the whole area. However, the filter can also be defined through CSS. We did not properly handle this case, and treated the node as if it had no filter at all. This computes the styles and checks the stylesheet as well. (We also move the logic down to avoid computing the styles eagerly.)
28 lines
850 B
Plaintext
28 lines
850 B
Plaintext
Empty <g> nodes should not be removed if they contain a filter, including
|
|
filters applied via CSS.
|
|
|
|
===
|
|
|
|
<svg viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">
|
|
<filter id="a" x="0" y="0" width="50" height="50" filterUnits="userSpaceOnUse">
|
|
<feFlood flood-color="#aaa"/>
|
|
</filter>
|
|
<mask id="b" x="0" y="0" width="50" height="50">
|
|
<g style="filter: url(#a)"/>
|
|
</mask>
|
|
<text x="16" y="16" style="mask: url(#b)">•ᴗ•</text>
|
|
</svg>
|
|
|
|
|
|
@@@
|
|
|
|
<svg viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">
|
|
<filter id="a" x="0" y="0" width="50" height="50" filterUnits="userSpaceOnUse">
|
|
<feFlood flood-color="#aaa"/>
|
|
</filter>
|
|
<mask id="b" x="0" y="0" width="50" height="50">
|
|
<g style="filter: url(#a)"/>
|
|
</mask>
|
|
<text x="16" y="16" style="mask: url(#b)">•ᴗ•</text>
|
|
</svg>
|