From f10df425e4c5d5cf40330c9ced9146dbb5633d07 Mon Sep 17 00:00:00 2001 From: JFH <20402845+jfhenon@users.noreply.github.com> Date: Thu, 27 May 2021 21:08:14 +0200 Subject: [PATCH] fix issue when URL for a fill color does not exist --- src/editor/components/PaintBox.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/editor/components/PaintBox.js b/src/editor/components/PaintBox.js index 6335cafe..f6c4b47e 100644 --- a/src/editor/components/PaintBox.js +++ b/src/editor/components/PaintBox.js @@ -71,11 +71,14 @@ class PaintBox { if (color.startsWith('url(#')) { let refElem = svgCanvas.getRefElem(color); refElem = (refElem) ? refElem.cloneNode(true) : document.querySelectorAll('#' + type + '_color defs *')[0]; + if (!refElem) { + console.error(`the color ${color} is referenced by an url that can't be identified - using 'none'`); + opts.solidColor = 'none'; + } else { opts[refElem.tagName] = refElem; + } } else if (color.startsWith('#')) { opts.solidColor = color.substr(1); - } else { - opts.solidColor = 'none'; } return new jGraduate.Paint(opts); }