-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Knight Chen
committed
Jun 10, 2023
1 parent
f491c00
commit 2cdd1d3
Showing
5 changed files
with
31 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const toString = (val: unknown): string => Object.prototype.toString.call(val) | ||
|
||
export function isDocument(val: unknown): val is Document { | ||
return toString(val) === '[object HTMLDocument]' | ||
} | ||
|
||
export function isShadowRoot(val: any): val is ShadowRoot { | ||
return toString(val) === '[object ShadowRoot]' | ||
} | ||
|
||
export function isDataTransfer(val: any): val is DataTransfer { | ||
return toString(val) === '[object DataTransfer]' | ||
} | ||
|
||
export function isSelection(val: any): val is Selection { | ||
return toString(val) === '[object Selection]' | ||
} | ||
|
||
export function isHTMLElement(val: any): val is HTMLElement { | ||
return !!val && Reflect.get(val, 'nodeType') === Node.ELEMENT_NODE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters