Permalink
Browse files

fix(dom utils): use getBoundingClientRect() to determine element visi…

…bility (#1203)

`Element.offsetParent`/`offsetHeight`/`offsetWidth` does not work on `<svg>` elements.

Swtching to `Element.getBoundingClientRect().height` and `.width` gets around this limitation
  • Loading branch information...
tmorehouse committed Oct 14, 2017
1 parent 960877c commit 6e2fff489b716fcddd4aeb0ce3a01b3f1f1e251c
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/utils/dom.js
@@ -52,7 +52,8 @@ dom.isElement = function(el) {
dom.isVisible = function(el) {
return dom.isElement(el) &&
document.body.contains(el) &&
(el.offsetParent !== null || el.offsetWidth > 0 || el.offsetHeight > 0);
el.getBoundingClientRect().height > 0 &&
el.getBoundingClientRect().width > 0
};
// Determine if an element is disabled

0 comments on commit 6e2fff4

Please sign in to comment.