From 7c4e225c01e8db10c687ec502e34b57169d4b65f Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Wed, 8 Mar 2017 14:44:45 +0100 Subject: fix documet.contains bug in IE (#612) --- src/boxes.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/boxes.js') 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() -- cgit v1.2.3