1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-31 07:44:22 +03:00

Keep empty <g> when filter attributes is specified

This commit is contained in:
Bogdan Chadkin
2021-02-23 22:36:47 +03:00
parent 776ec1e71b
commit c1d5f0f7a9
2 changed files with 32 additions and 4 deletions

View File

@ -25,8 +25,13 @@ var container = require('./_collections').elemsGroups.container;
* @author Kir Belevich * @author Kir Belevich
*/ */
exports.fn = function(item) { exports.fn = function(item) {
return (
return !(item.isElem(container) && !item.isElem('svg') && item.isEmpty() && item.isElem(container) === false ||
(!item.isElem('pattern') || !item.hasAttrLocal('href'))); item.isEmpty() === false ||
item.isElem('svg') ||
(item.isElem('pattern') && item.hasAttrLocal('href')) ||
// The 'g' may not have content, but the filter may cause a rectangle
// to be created and filled with pattern.
(item.isElem('g') && item.hasAttr('filter'))
);
}; };

View File

@ -0,0 +1,23 @@
<svg>
<defs>
<filter id="feTileFilter" filterUnits="userSpaceOnUse" primitiveUnits="userSpaceOnUse" x="115" y="40" width="250" height="250">
<feFlood x="115" y="40" width="54" height="19" flood-color="lime"/>
<feOffset x="115" y="40" width="50" height="25" dx="6" dy="6" result="offset"/>
<feTile/>
</filter>
</defs>
<g filter="url(#feTileFilter)"/>
</svg>
@@@
<svg>
<defs>
<filter id="feTileFilter" filterUnits="userSpaceOnUse" primitiveUnits="userSpaceOnUse" x="115" y="40" width="250" height="250">
<feFlood x="115" y="40" width="54" height="19" flood-color="lime"/>
<feOffset x="115" y="40" width="50" height="25" dx="6" dy="6" result="offset"/>
<feTile/>
</filter>
</defs>
<g filter="url(#feTileFilter)"/>
</svg>

After

Width:  |  Height:  |  Size: 816 B