@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
19 lines • 903 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNearestOverflowAncestor = void 0;
const getParentNode_1 = require("./getParentNode");
const is_utils_1 = require("./is.utils");
const getNearestOverflowAncestor = (node) => {
const parentNode = (0, getParentNode_1.getParentNode)(node);
if ((0, is_utils_1.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 ((0, is_utils_1.isHTMLElement)(parentNode) && (0, is_utils_1.isOverflowElement)(parentNode)) {
return parentNode;
}
return (0, exports.getNearestOverflowAncestor)(parentNode);
};
exports.getNearestOverflowAncestor = getNearestOverflowAncestor;
//# sourceMappingURL=getNearestOverflowAncestor.js.map