Debian Codegraph @

packages/popper/src/utils/getFixedPositionOffsetParent.js

raw
1 import getStyleComputedProperty from './getStyleComputedProperty';
2 import isIE from './isIE';
3 /**
4 * Finds the first parent of an element that has a transformed property defined
5 * @method
6 * @memberof Popper.Utils
7 * @argument {Element} element
8 * @returns {Element} first transformed parent or documentElement
9 */
10
11 export default function getFixedPositionOffsetParent(element) {
12 // This check is needed to avoid errors in case one of the elements isn't defined for any reason
13 if (!element || !element.parentElement || isIE()) {
14 return document.documentElement;
15 }
16 let el = element.parentElement;
17 while (el && getStyleComputedProperty(el, 'transform') === 'none') {
18 el = el.parentElement;
19 }
20 return el || document.documentElement;
21
22 }