From 486cb620afb3573649c171ccbddc9ad21f5ffacc Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 31 Mar 2016 21:40:37 +0200 Subject: [PATCH] Call getComputedTextLength() only on child elements of document.body Otherwise IE/Edge can throw exceptions. --- src/plots/plots.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plots/plots.js b/src/plots/plots.js index bc519f70687..f3f1234b627 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -345,10 +345,11 @@ plots.addLinks = function(gd) { }; // If text's width is bigger than the layout - // IE doesn't like getComputedTextLength if an element - // isn't visible, which it (sometimes?) isn't - // apparently offsetParent is null for invisibles. - if(text && text.getComputedTextLength() >= (fullLayout.width - 20)) { + // Check that text is a child node or document.body + // because otherwise IE/Edge might throw an exception + // when calling getComputedTextLength(). + // Apparently offsetParent is null for invisibles. + if(document.body.contains(text) && text.getComputedTextLength() >= (fullLayout.width - 20)) { // Align the text at the left attrs['text-anchor'] = 'start'; attrs.x = 5;