UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

15 lines 682 B
import { getParentNode } from './getParentNode'; import { isHTMLElement, isLastTraversableNode, isOverflowElement } from './is.utils'; export const getNearestOverflowAncestor = (node) => { const parentNode = getParentNode(node); if (isLastTraversableNode(parentNode)) { // `getParentNode` will never return a `Document` due to the fallback // check, so it's either the <html> or <body> element. return parentNode.ownerDocument.body; } if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { return parentNode; } return getNearestOverflowAncestor(parentNode); }; //# sourceMappingURL=getNearestOverflowAncestor.js.map