From 2c1bf5a4095df2d15f36ea5a3341bf9a9a133217 Mon Sep 17 00:00:00 2001 From: Milovan Zogovic Date: Fri, 22 Jan 2016 14:32:51 +0100 Subject: [PATCH] Update element.js I've encountered situation where SVG.adopt (line 176) returns null, which leads to `Uncaught TypeError: Cannot read property 'node' of null`. Checking whether parent exists fixes it. --- src/element.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/element.js b/src/element.js index 090459f..75d77dc 100644 --- a/src/element.js +++ b/src/element.js @@ -171,7 +171,7 @@ SVG.Element = SVG.invent({ if(!type) return parent // loop trough ancestors if type is given - while(parent.node instanceof SVGElement){ + while(parent && parent.node instanceof SVGElement){ if(typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent parent = SVG.adopt(parent.node.parentNode) } -- 2.39.5