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:
@@ -8,7 +8,8 @@ exports.description = 'removes useless stroke and fill attributes';
|
|||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
stroke: true,
|
stroke: true,
|
||||||
fill: true
|
fill: true,
|
||||||
|
removeNone: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var shape = require('./_collections').elemsGroups.shape,
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
24
test/plugins/removeUselessStrokeAndFill.02_.svg
Normal file
24
test/plugins/removeUselessStrokeAndFill.02_.svg
Normal 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 |
Reference in New Issue
Block a user