summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilovan Zogovic <milovan.zogovic@gmail.com>2016-01-22 14:32:51 +0100
committerMilovan Zogovic <milovan.zogovic@gmail.com>2016-01-22 14:32:51 +0100
commit2c1bf5a4095df2d15f36ea5a3341bf9a9a133217 (patch)
tree5b05b641a43afbb6e8b2c9d82be5ab2a6dbcc2d9
parentd17bab6bcccc8319b8b4c96db0def8926e93152d (diff)
downloadsvg.js-2c1bf5a4095df2d15f36ea5a3341bf9a9a133217.tar.gz
svg.js-2c1bf5a4095df2d15f36ea5a3341bf9a9a133217.zip
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.
-rw-r--r--src/element.js2
1 files changed, 1 insertions, 1 deletions
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)
}