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:
@ -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'))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
23
test/plugins/removeEmptyContainers.04.svg
Normal file
23
test/plugins/removeEmptyContainers.04.svg
Normal 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 |
Reference in New Issue
Block a user