mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
13 lines
494 B
TypeScript
13 lines
494 B
TypeScript
/**
|
|
* Utility function to check if a root node contains a child node across shadow DOM boundaries.
|
|
*/
|
|
export function containsComposedNode(rootNode: Node, childNode: Node): boolean {
|
|
if (!rootNode || !childNode) return false;
|
|
if (rootNode?.contains(childNode)) return true;
|
|
const childRootNode = childNode.getRootNode();
|
|
if (childRootNode && 'host' in childRootNode && childRootNode.host) {
|
|
return containsComposedNode(rootNode, childRootNode.host as Node);
|
|
}
|
|
return false;
|
|
}
|