1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +03:00

Allow empty pattern when any attribute is present

This commit is contained in:
Bogdan Chadkin
2021-03-06 02:33:19 +03:00
parent ba7e9bdc0d
commit 0e6b0c4a01
2 changed files with 5 additions and 4 deletions

View File

@ -24,12 +24,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) === false || item.isElem(container) === false ||
item.isEmpty() === false || item.isEmpty() === false ||
item.isElem('svg') || 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 // The 'g' may not have content, but the filter may cause a rectangle
// to be created and filled with pattern. // to be created and filled with pattern.
(item.isElem('g') && item.hasAttr('filter')) || (item.isElem('g') && item.hasAttr('filter')) ||

View File

@ -95,6 +95,8 @@ const runTests = async ({ svgFiles }) => {
if ( if (
// hard to detect the end of animation // hard to detect the end of animation
name.startsWith('animate-') || name.startsWith('animate-') ||
// breaks because of optimisation despite of script
name === 'interact-pointer-04-f' ||
// other cases which require complex changes // other cases which require complex changes
name === 'painting-marker-07-f' || name === 'painting-marker-07-f' ||
name === 'pservers-grad-18-b' || name === 'pservers-grad-18-b' ||
@ -108,8 +110,6 @@ const runTests = async ({ svgFiles }) => {
// unstable test // unstable test
name === 'filters-light-04-f' || name === 'filters-light-04-f' ||
// mismatched draft cases // mismatched draft cases
name === 'interact-pointer-04-f' ||
name === 'pservers-pattern-05-f' ||
name === 'struct-cond-overview-03-f' || name === 'struct-cond-overview-03-f' ||
name === 'struct-use-07-b' || name === 'struct-use-07-b' ||
name === 'styling-css-10-f' || name === 'styling-css-10-f' ||