UNPKG

ui-lit

Version:

UI Elements on LIT

22 lines (21 loc) 679 B
const _set = new Set(); export const getRootRalitive = (current) => { _set.clear(); while (window.getComputedStyle(current).position !== 'relative') { if (current.shadowRoot) { const slot = current.shadowRoot.querySelector('slot:not([name])'); if (slot && !_set.has(slot)) { _set.add(slot); current = slot; } } current = current.parentNode; if (current instanceof ShadowRoot) { current = current.host; } if (current === document.body || !current) { return document.body; } } return current; };