summaryrefslogtreecommitdiffstats
path: root/src/boxes.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-03-08 14:44:45 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-03-08 14:44:45 +0100
commit7c4e225c01e8db10c687ec502e34b57169d4b65f (patch)
treeeb383085d5a857541ab3cb98f14bb980acf0c42d /src/boxes.js
parent0534a6760a094d5a9425bde1d89bb8b71ae6a798 (diff)
downloadsvg.js-7c4e225c01e8db10c687ec502e34b57169d4b65f.tar.gz
svg.js-7c4e225c01e8db10c687ec502e34b57169d4b65f.zip
fix documet.contains bug in IE (#612)
Diffstat (limited to 'src/boxes.js')
-rw-r--r--src/boxes.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/boxes.js b/src/boxes.js
index 9d2ef04..3a373b8 100644
--- a/src/boxes.js
+++ b/src/boxes.js
@@ -71,8 +71,17 @@ SVG.BBox = SVG.invent({
// yes this is ugly, but Firefox can be a bitch when it comes to elements that are not yet rendered
try {
- // the element is NOT in the dom, throw error
- if(!document.documentElement.contains(element.node)) throw new Exception('Element not in the dom')
+ if (!document.documentElement.contains){
+ // This is IE - it does not support contains() for top-level SVGs
+ var topParent = element.node;
+ while (topParent.parentNode){
+ topParent = topParent.parentNode;
+ }
+ if (topParent != document) throw new Exception('Element not in the dom')
+ } else {
+ // the element is NOT in the dom, throw error
+ if(!document.documentElement.contains(element.node)) throw new Exception('Element not in the dom')
+ }
// find native bbox
box = element.node.getBBox()