Skip to content

Commit

Permalink
fix: dom not appended should not be treated as ShadowRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc committed Aug 3, 2023
1 parent 2ced0b2 commit 1b69b0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Dom/shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function getRoot(ele: Node) {
* Check if is in shadowRoot
*/
export function inShadow(ele: Node) {
return getRoot(ele) !== ele?.ownerDocument;
return getRoot(ele) instanceof ShadowRoot;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/shadow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ describe('shadow', () => {

expect(getShadowRoot(button)).toBeNull();
});

it('should return null if dom is not appended', () => {
const button = document.createElement('button');
expect(getShadowRoot(button)).toBeNull();
});
});
});

0 comments on commit 1b69b0f

Please sign in to comment.