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

18 lines 598 B
import { isShadowRoot } from './is.utils'; import { getNodeName } from './node'; export const getParentNode = (node) => { if (getNodeName(node) === 'html') { return node; } const result = // Step into the shadow DOM of the parent of a slotted node. node.assignedSlot || // DOM Element detected. node.parentNode || // ShadowRoot detected. (isShadowRoot(node) && node.host) || // Fallback. window.document.documentElement; return isShadowRoot(result) ? result.host : result; }; //# sourceMappingURL=getParentNode.js.map