1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-31 07:44:22 +03:00

removeUselessStrokeAndFill.js: use String.startsWith() (#1522)

This commit is contained in:
XhmikosR
2021-08-14 13:09:57 +03:00
committed by GitHub
parent 87ad664659
commit b41c6fe473

View File

@ -16,8 +16,6 @@ exports.params = {
};
var shape = require('./_collections').elemsGroups.shape,
regStrokeProps = /^stroke/,
regFillProps = /^fill-/,
styleOrScript = ['style', 'script'];
/**
@ -59,7 +57,7 @@ exports.fn = function (item, params) {
declineStroke = parentStroke && parentStroke != 'none';
for (const name of Object.keys(item.attributes)) {
if (regStrokeProps.test(name)) {
if (name.startsWith('stroke')) {
delete item.attributes[name];
}
}
@ -73,7 +71,7 @@ exports.fn = function (item, params) {
// remove fill*
if (params.fill && (!fill || item.computedAttr('fill-opacity', '0'))) {
for (const name of Object.keys(item.attributes)) {
if (regFillProps.test(name)) {
if (name.startsWith('fill-')) {
delete item.attributes[name];
}
}