Skip to content

Commit

Permalink
fix: check for element in normal scope first (#123)
Browse files Browse the repository at this point in the history
* Fix check for element in iframe vs normal scope

* swapping check for element instance

* Refactor for Element check

* Missing semi-colon
  • Loading branch information
JayaKrishnaNamburu authored Apr 15, 2021
1 parent 22c1dda commit 309788b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const isHidden = (target: Element): boolean => {

// Checks if an object is an Element
const isElement = (obj: unknown): boolean => {
if (obj instanceof Element) {
return true;
}
const scope = (obj as Element)?.ownerDocument?.defaultView;
return !!(scope && obj instanceof (scope as unknown as typeof globalThis).Element);
};
Expand Down

0 comments on commit 309788b

Please sign in to comment.