We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 08ef5a2 commit 61b1db2Copy full SHA for 61b1db2
src/Dom/shadow.ts
@@ -1,7 +1,17 @@
1
+function getRoot(ele: Node) {
2
+ return ele?.getRootNode?.();
3
+}
4
+
5
+/**
6
+ * Check if is in shadowRoot
7
+ */
8
export function inShadow(ele: Node) {
- return ele?.getRootNode() !== ele?.ownerDocument;
9
+ return getRoot(ele) !== ele?.ownerDocument;
10
}
11
12
13
+ * Return shadowRoot if possible
14
15
export function getShadowRoot(ele: Node): ShadowRoot {
- return inShadow(ele) ? (ele?.getRootNode() as ShadowRoot) : null;
16
+ return inShadow(ele) ? (getRoot(ele) as ShadowRoot) : null;
17
0 commit comments