Skip to content

Commit cc74b27

Browse files
authored
fix: dom not appended should not be treated as ShadowRoot (#457)
1 parent 2ced0b2 commit cc74b27

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Dom/shadow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function getRoot(ele: Node) {
66
* Check if is in shadowRoot
77
*/
88
export function inShadow(ele: Node) {
9-
return getRoot(ele) !== ele?.ownerDocument;
9+
return getRoot(ele) instanceof ShadowRoot;
1010
}
1111

1212
/**

tests/shadow.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@ describe('shadow', () => {
1919

2020
expect(getShadowRoot(button)).toBeNull();
2121
});
22+
23+
it('should return null if dom is not appended', () => {
24+
const button = document.createElement('button');
25+
expect(getShadowRoot(button)).toBeNull();
26+
});
2227
});
2328
});

0 commit comments

Comments
 (0)