From 7bb89f53a5f0447f6136b10f306be2485e1ceb78 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Thu, 17 May 2018 12:04:58 -0700 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20throw=20error=20for=20unlinked?= =?UTF-8?q?=20nodes=20in=20Chrome?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit evt.target in Chrome is the abandoned shape, not connected to the DOM. evt.target in Firefox is the svgroot. Add checks to ensure that no matter what node is presented by the event, there are no property calls to null or undefined. Fixes issue #232. --- editor/svgcanvas.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index d52b50fc..2ed645d8 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -2205,13 +2205,14 @@ var mouseUp = function (evt) { // if this element is in a group, go up until we reach the top-level group // just below the layer groups // TODO: once we implement links, we also would have to check for elements - while (t.parentNode.parentNode.tagName === 'g') { + while (t && t.parentNode && t.parentNode.parentNode && t.parentNode.parentNode.tagName === 'g') { t = t.parentNode; } // if we are not in the middle of creating a path, and we've clicked on some shape, // then go to Select mode. // WebKit returns
when the canvas is clicked, Firefox/Opera return if ((currentMode !== 'path' || !drawnPath) && + t && t.parentNode && t.parentNode.id !== 'selectorParentGroup' && t.id !== 'svgcanvas' && t.id !== 'svgroot' ) {