Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 486cb62

Browse files
committed
Call getComputedTextLength() only on child elements of document.body
Otherwise IE/Edge can throw exceptions.
1 parent 5c53f8f commit 486cb62

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/plots/plots.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,11 @@ plots.addLinks = function(gd) {
345345
};
346346

347347
// If text's width is bigger than the layout
348-
// IE doesn't like getComputedTextLength if an element
349-
// isn't visible, which it (sometimes?) isn't
350-
// apparently offsetParent is null for invisibles.
351-
if(text && text.getComputedTextLength() >= (fullLayout.width - 20)) {
348+
// Check that text is a child node or document.body
349+
// because otherwise IE/Edge might throw an exception
350+
// when calling getComputedTextLength().
351+
// Apparently offsetParent is null for invisibles.
352+
if(document.body.contains(text) && text.getComputedTextLength() >= (fullLayout.width - 20)) {
352353
// Align the text at the left
353354
attrs['text-anchor'] = 'start';
354355
attrs.x = 5;

0 commit comments

Comments
 (0)