Skip to content

Commit

Permalink
Keep empty <g> when filter attributes is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Feb 23, 2021
1 parent 776ec1e commit c1d5f0f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugins/removeEmptyContainers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
);
};
23 changes: 23 additions & 0 deletions test/plugins/removeEmptyContainers.04.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c1d5f0f

Please sign in to comment.