mirror of
https://github.com/svg/svgo.git
synced 2025-08-09 02:22:08 +03:00
removeUselessStrokeAndFill.js: use String.startsWith()
(#1522)
This commit is contained in:
@@ -16,8 +16,6 @@ exports.params = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var shape = require('./_collections').elemsGroups.shape,
|
var shape = require('./_collections').elemsGroups.shape,
|
||||||
regStrokeProps = /^stroke/,
|
|
||||||
regFillProps = /^fill-/,
|
|
||||||
styleOrScript = ['style', 'script'];
|
styleOrScript = ['style', 'script'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +57,7 @@ exports.fn = function (item, params) {
|
|||||||
declineStroke = parentStroke && parentStroke != 'none';
|
declineStroke = parentStroke && parentStroke != 'none';
|
||||||
|
|
||||||
for (const name of Object.keys(item.attributes)) {
|
for (const name of Object.keys(item.attributes)) {
|
||||||
if (regStrokeProps.test(name)) {
|
if (name.startsWith('stroke')) {
|
||||||
delete item.attributes[name];
|
delete item.attributes[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +71,7 @@ exports.fn = function (item, params) {
|
|||||||
// remove fill*
|
// remove fill*
|
||||||
if (params.fill && (!fill || item.computedAttr('fill-opacity', '0'))) {
|
if (params.fill && (!fill || item.computedAttr('fill-opacity', '0'))) {
|
||||||
for (const name of Object.keys(item.attributes)) {
|
for (const name of Object.keys(item.attributes)) {
|
||||||
if (regFillProps.test(name)) {
|
if (name.startsWith('fill-')) {
|
||||||
delete item.attributes[name];
|
delete item.attributes[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user