From 30e21e5d1c1e201fae50e036ace0a61396cb1626 Mon Sep 17 00:00:00 2001 From: DD Date: Fri, 20 Oct 2017 15:57:48 -0400 Subject: [PATCH] Fix color matching logic in apply stroke color --- src/helper/style-path.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/helper/style-path.js b/src/helper/style-path.js index 7fea6770..43e44fd2 100644 --- a/src/helper/style-path.js +++ b/src/helper/style-path.js @@ -50,6 +50,11 @@ const applyFillColorToSelection = function (colorString, onUpdateSvg) { } }; +const _strokeColorMatch = function (item, incomingColor) { + return (!item.strokeColor && !incomingColor) || + (item.strokeColor && incomingColor && item.strokeColor.toCSS() === new paper.Color(incomingColor).toCSS()); +}; + /** * Called when setting stroke color * @param {string} colorString New color, css format @@ -65,8 +70,7 @@ const applyStrokeColorToSelection = function (colorString, onUpdateSvg) { if (child.children) { for (const path of child.children) { if (!path.data.isPGGlyphRect) { - if ((path.strokeColor === null && colorString) || - path.strokeColor.toCSS() !== new paper.Color(colorString).toCSS()) { + if (!_strokeColorMatch(path, colorString)) { changed = true; path.strokeColor = colorString; } @@ -80,14 +84,12 @@ const applyStrokeColorToSelection = function (colorString, onUpdateSvg) { } } } else if (!item.data.isPGGlyphRect) { - if ((item.strokeColor === null && colorString) || - item.strokeColor.toCSS() !== new paper.Color(colorString).toCSS()) { + if (!_strokeColorMatch(item, colorString)) { changed = true; item.strokeColor = colorString; } } - } else if ((item.strokeColor === null && colorString) || - item.strokeColor.toCSS() !== new paper.Color(colorString).toCSS()) { + } else if (!_strokeColorMatch(item, colorString)) { changed = true; item.strokeColor = colorString; }