PromoCursed/node_modules/rc-util/es/Dom/shadow.js
2024-08-20 23:25:37 +04:00

18 lines
452 B
JavaScript

function getRoot(ele) {
var _ele$getRootNode;
return ele === null || ele === void 0 || (_ele$getRootNode = ele.getRootNode) === null || _ele$getRootNode === void 0 ? void 0 : _ele$getRootNode.call(ele);
}
/**
* Check if is in shadowRoot
*/
export function inShadow(ele) {
return getRoot(ele) instanceof ShadowRoot;
}
/**
* Return shadowRoot if possible
*/
export function getShadowRoot(ele) {
return inShadow(ele) ? getRoot(ele) : null;
}