mirror of
https://github.com/svg/svgo.git
synced 2025-07-31 07:44:22 +03:00
Disable removeUselessStrokeAndFill if there is a <style> or <script>
This commit is contained in:
@ -11,7 +11,9 @@ exports.params = {
|
|||||||
|
|
||||||
var shape = require('./_collections').elemsGroups.shape,
|
var shape = require('./_collections').elemsGroups.shape,
|
||||||
regStrokeProps = /^stroke/,
|
regStrokeProps = /^stroke/,
|
||||||
regFillProps = /^fill-/;
|
regFillProps = /^fill-/,
|
||||||
|
styleOrScript = ['style', 'script'],
|
||||||
|
hasStyleOrScript = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove useless stroke and fill attrs.
|
* Remove useless stroke and fill attrs.
|
||||||
@ -24,7 +26,11 @@ var shape = require('./_collections').elemsGroups.shape,
|
|||||||
*/
|
*/
|
||||||
exports.fn = function(item, params) {
|
exports.fn = function(item, params) {
|
||||||
|
|
||||||
if (item.isElem(shape) && !item.computedAttr('id')) {
|
if (item.isElem(styleOrScript)) {
|
||||||
|
hasStyleOrScript = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasStyleOrScript && item.isElem(shape) && !item.computedAttr('id')) {
|
||||||
|
|
||||||
var stroke = params.stroke && item.computedAttr('stroke'),
|
var stroke = params.stroke && item.computedAttr('stroke'),
|
||||||
fill = params.fill && !item.computedAttr('fill', 'none');
|
fill = params.fill && !item.computedAttr('fill', 'none');
|
||||||
|
21
test/plugins/removeUselessStrokeAndFill.03.svg
Normal file
21
test/plugins/removeUselessStrokeAndFill.03.svg
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<style>
|
||||||
|
…
|
||||||
|
</style>
|
||||||
|
<circle fill="none" fill-rule="evenodd" cx="60" cy="60" r="50"/>
|
||||||
|
<circle fill-opacity="0" fill-rule="evenodd" cx="90" cy="60" r="50"/>
|
||||||
|
<circle fill="red" stroke-width="6" stroke-dashoffset="5" cx="60" cy="60" r="50"/>
|
||||||
|
<circle fill="red" stroke="#000" stroke-width="6" stroke-dashoffset="5" stroke-opacity="0" cx="60" cy="60" r="50"/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
@@@
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<style>
|
||||||
|
…
|
||||||
|
</style>
|
||||||
|
<circle fill="none" fill-rule="evenodd" cx="60" cy="60" r="50"/>
|
||||||
|
<circle fill-opacity="0" fill-rule="evenodd" cx="90" cy="60" r="50"/>
|
||||||
|
<circle fill="red" stroke-width="6" stroke-dashoffset="5" cx="60" cy="60" r="50"/>
|
||||||
|
<circle fill="red" stroke="#000" stroke-width="6" stroke-dashoffset="5" stroke-opacity="0" cx="60" cy="60" r="50"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 876 B |
Reference in New Issue
Block a user