1
0
mirror of https://github.com/svg/svgo.git synced 2025-08-09 02:22:08 +03:00

additional option for removeUselessFillStroke, to actually remove invisible shapes

This commit is contained in:
caub
2017-01-27 22:50:06 +01:00
parent 2608ae1467
commit 5a1693bd5e
2 changed files with 33 additions and 1 deletions

View File

@@ -8,7 +8,8 @@ exports.description = 'removes useless stroke and fill attributes';
exports.params = {
stroke: true,
fill: true
fill: true,
removeNone: false
};
var shape = require('./_collections').elemsGroups.shape,
@@ -87,6 +88,13 @@ exports.fn = function(item, params) {
}
}
if (params.removeNone &&
(!stroke || item.hasAttr('stroke') && item.attr('stroke').value=='none') &&
(!fill || item.hasAttr('fill') && item.attr('fill').value=='none')) {
return false;
}
}
};

View File

@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
<g id="test">
<rect fill-opacity=".5" width="100" height="100"/>
</g>
</defs>
<circle fill="none" fill-rule="evenodd" cx="60" cy="60" r="50"/>
<circle fill="red" fill-opacity="0" cx="90" cy="90" r="50"/>
<circle fill-opacity="0" fill-rule="evenodd" cx="90" cy="60" r="50"/>
<circle fill="red" fill-opacity=".5" cx="60" cy="60" r="50"/>
<g fill="none">
<circle fill-opacity=".5" cx="60" cy="60" r="50"/>
</g>
</svg>
@@@
<svg xmlns="http://www.w3.org/2000/svg">
<circle fill="red" fill-opacity=".5" cx="60" cy="60" r="50"/>
</svg>
@@@
{ "removeNone": true }

After

Width:  |  Height:  |  Size: 679 B