UNPKG

@chakra-ui/dom-utils

Version:

A Quick description of the component

29 lines (26 loc) 737 B
import { isHTMLElement } from "./chunk-3XANSPY5.mjs"; // src/scroll.ts function isScrollParent(el) { const win = el.ownerDocument.defaultView || window; const { overflow, overflowX, overflowY } = win.getComputedStyle(el); return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX); } function getParent(el) { if (el.localName === "html") return el; return el.assignedSlot || el.parentElement || el.ownerDocument.documentElement; } function getScrollParent(el) { if (["html", "body", "#document"].includes(el.localName)) { return el.ownerDocument.body; } if (isHTMLElement(el) && isScrollParent(el)) { return el; } return getScrollParent(getParent(el)); } export { getScrollParent };