mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
35 lines
1.2 KiB
let shadowDomIsSupported;
|
|
function _supportsShadowDom() {
|
|
if (shadowDomIsSupported == null) {
|
|
const head = typeof document !== 'undefined' ? document.head : null;
|
|
shadowDomIsSupported = !!(head && (head.createShadowRoot || head.attachShadow));
|
|
}
|
|
return shadowDomIsSupported;
|
|
}
|
|
function _getShadowRoot(element) {
|
|
if (_supportsShadowDom()) {
|
|
const rootNode = element.getRootNode ? element.getRootNode() : null;
|
|
if (typeof ShadowRoot !== 'undefined' && ShadowRoot && rootNode instanceof ShadowRoot) {
|
|
return rootNode;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function _getFocusedElementPierceShadowDom() {
|
|
let activeElement = typeof document !== 'undefined' && document ? document.activeElement : null;
|
|
while (activeElement && activeElement.shadowRoot) {
|
|
const newActiveElement = activeElement.shadowRoot.activeElement;
|
|
if (newActiveElement === activeElement) {
|
|
break;
|
|
} else {
|
|
activeElement = newActiveElement;
|
|
}
|
|
}
|
|
return activeElement;
|
|
}
|
|
function _getEventTarget(event) {
|
|
return event.composedPath ? event.composedPath()[0] : event.target;
|
|
}
|
|
|
|
export { _getEventTarget, _getFocusedElementPierceShadowDom, _getShadowRoot, _supportsShadowDom };
|
|
//# sourceMappingURL=_shadow-dom-chunk.mjs.map
|
|
|