From 0e6b0c4a0182fb79775fb6af2f1df18c12f917d9 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Sat, 6 Mar 2021 02:33:19 +0300 Subject: [PATCH] Allow empty pattern when any attribute is present --- plugins/removeEmptyContainers.js | 5 +++-- test/regression.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/removeEmptyContainers.js b/plugins/removeEmptyContainers.js index 28fde16c2..f34e5108a 100644 --- a/plugins/removeEmptyContainers.js +++ b/plugins/removeEmptyContainers.js @@ -24,12 +24,13 @@ var container = require('./_collections').elemsGroups.container; * * @author Kir Belevich */ -exports.fn = function(item) { +exports.fn = function (item) { return ( item.isElem(container) === false || item.isEmpty() === false || item.isElem('svg') || - (item.isElem('pattern') && item.hasAttrLocal('href')) || + // empty patterns may contain reusable configuration + (item.isElem('pattern') && Object.keys(item.attrs).length !== 0) || // 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')) || diff --git a/test/regression.js b/test/regression.js index 3b84047d3..13de8c616 100644 --- a/test/regression.js +++ b/test/regression.js @@ -95,6 +95,8 @@ const runTests = async ({ svgFiles }) => { if ( // hard to detect the end of animation name.startsWith('animate-') || + // breaks because of optimisation despite of script + name === 'interact-pointer-04-f' || // other cases which require complex changes name === 'painting-marker-07-f' || name === 'pservers-grad-18-b' || @@ -108,8 +110,6 @@ const runTests = async ({ svgFiles }) => { // unstable test name === 'filters-light-04-f' || // mismatched draft cases - name === 'interact-pointer-04-f' || - name === 'pservers-pattern-05-f' || name === 'struct-cond-overview-03-f' || name === 'struct-use-07-b' || name === 'styling-css-10-f' ||