diff --git a/src/dom-utils/getOffsetParent.js b/src/dom-utils/getOffsetParent.js index f64a8fe726..38fb137acc 100644 --- a/src/dom-utils/getOffsetParent.js +++ b/src/dom-utils/getOffsetParent.js @@ -23,21 +23,22 @@ function getTrueOffsetParent(element: Element): ?Element { function getContainingBlock(element: Element) { let currentNode = getParentNode(element); - while (getNodeName(currentNode) !== 'body') { - if (isHTMLElement(currentNode)) { - const css = getComputedStyle(currentNode); + while ( + isHTMLElement(currentNode) && + ['html', 'body'].indexOf(getNodeName(currentNode)) < 0 + ) { + const css = getComputedStyle(currentNode); - // This is non-exhaustive but covers the most common CSS properties that - // create a containing block. - if ( - css.transform !== 'none' || - css.perspective !== 'none' || - css.willChange !== 'auto' - ) { - return currentNode; - } else { - currentNode = currentNode.parentNode; - } + // This is non-exhaustive but covers the most common CSS properties that + // create a containing block. + if ( + css.transform !== 'none' || + css.perspective !== 'none' || + css.willChange !== 'auto' + ) { + return currentNode; + } else { + currentNode = currentNode.parentNode; } }