Skip to content

Commit

Permalink
Merge pull request #1129 from atomiks/patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
FezVrasta committed Jun 10, 2020
2 parents f2b619b + 35f4141 commit 38914aa
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/dom-utils/getOffsetParent.js
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 38914aa

Please sign in to comment.