From b41c6fe473ea566cef660cb3597e9e57585be9e1 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 14 Aug 2021 13:09:57 +0300 Subject: [PATCH] removeUselessStrokeAndFill.js: use `String.startsWith()` (#1522) --- plugins/removeUselessStrokeAndFill.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/removeUselessStrokeAndFill.js b/plugins/removeUselessStrokeAndFill.js index 2b65eae9..945aeda7 100644 --- a/plugins/removeUselessStrokeAndFill.js +++ b/plugins/removeUselessStrokeAndFill.js @@ -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]; } }