UNPKG

@vuesax-alpha/nightly

Version:
29 lines (26 loc) 1.11 kB
import { isHTMLElement, getWindow, isTableElement, getNodeName, isContainingBlock, getContainingBlock } from '../../utils/dom.mjs'; function getTrueOffsetParent(element, polyfill) { if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") { return null; } if (polyfill) { return polyfill(element); } return element.offsetParent; } function getOffsetParent(element, polyfill) { const window = getWindow(element); if (!isHTMLElement(element)) { return window; } let offsetParent = getTrueOffsetParent(element, polyfill); while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") { offsetParent = getTrueOffsetParent(offsetParent, polyfill); } if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) { return window; } return offsetParent || getContainingBlock(element) || window; } export { getOffsetParent }; //# sourceMappingURL=get-offset-parent.mjs.map