From 015ba10673301cb6031c2f5f544a9b4ca565ac95 Mon Sep 17 00:00:00 2001 From: Michael Deal Date: Tue, 10 Jul 2018 23:32:21 -0700 Subject: [PATCH] Ensure `element` exists when setting fill-rule --- canvas2svg.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/canvas2svg.js b/canvas2svg.js index b99e03f..dea6b96 100644 --- a/canvas2svg.js +++ b/canvas2svg.js @@ -758,11 +758,12 @@ */ ctx.prototype.fill = function () { var element = getOrCreateElementToApplyStyleTo.call(this, "fill", "stroke"); - - /** `fillRule` could be first or second argument: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fill **/ - if (arguments[0] === "evenodd" || arguments[1] === "evenodd") { - element.setAttribute("fill-rule", "evenodd"); - } + if (element) { + /** `fillRule` could be first or second argument: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fill **/ + if (arguments[0] === "evenodd" || arguments[1] === "evenodd") { + element.setAttribute("fill-rule", "evenodd"); + } + } }; /**