1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +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
*/
exports.fn = function(item) {
return !(item.isElem(container) && !item.isElem('svg') && item.isEmpty() &&
(!item.isElem('pattern') || !item.hasAttrLocal('href')));
return (
item.isElem(container) === false ||
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'))
);
};