fix issue when URL for a fill color does not exist

master
JFH 2021-05-27 21:08:14 +02:00
parent 9a2e4b664b
commit f10df425e4
1 changed files with 5 additions and 2 deletions

View File

@ -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);
}