Don’t throw error for unlinked nodes in Chrome

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.
master
Neil Fraser 2018-05-17 12:04:58 -07:00
parent f9fb7f47ae
commit 7bb89f53a5
1 changed files with 2 additions and 1 deletions

View File

@ -2205,13 +2205,14 @@ var mouseUp = function (evt) {
// if this element is in a group, go up until we reach the top-level group // if this element is in a group, go up until we reach the top-level group
// just below the layer groups // just below the layer groups
// TODO: once we implement links, we also would have to check for <a> elements // TODO: once we implement links, we also would have to check for <a> elements
while (t.parentNode.parentNode.tagName === 'g') { while (t && t.parentNode && t.parentNode.parentNode && t.parentNode.parentNode.tagName === 'g') {
t = t.parentNode; t = t.parentNode;
} }
// if we are not in the middle of creating a path, and we've clicked on some shape, // if we are not in the middle of creating a path, and we've clicked on some shape,
// then go to Select mode. // then go to Select mode.
// WebKit returns <div> when the canvas is clicked, Firefox/Opera return <svg> // WebKit returns <div> when the canvas is clicked, Firefox/Opera return <svg>
if ((currentMode !== 'path' || !drawnPath) && if ((currentMode !== 'path' || !drawnPath) &&
t && t.parentNode &&
t.parentNode.id !== 'selectorParentGroup' && t.parentNode.id !== 'selectorParentGroup' &&
t.id !== 'svgcanvas' && t.id !== 'svgroot' t.id !== 'svgcanvas' && t.id !== 'svgroot'
) { ) {