Skip to content

Commit e3eabab

Browse files
authored
Merge pull request #5 from abcnews/bug/types
bug: BlockMount is a div
2 parents 625a1be + e687929 commit e3eabab

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ type MountValue = string;
22
type MountValuePrefix = string;
33
type MountSelector = string;
44
type MountSelectorTemplate = string[];
5-
type BlockMount = Element & {
6-
tagName: 'DIV';
5+
type BlockMount = HTMLDivElement & {
76
id: MountValue;
87
dataset: {
98
mount: string;
@@ -67,8 +66,8 @@ function isNode(x: unknown): x is Node {
6766
return typeof x === 'object' && x instanceof Node;
6867
}
6968

70-
function isElement(x: unknown): x is Element {
71-
return isNode(x) && x.nodeType === Node.ELEMENT_NODE;
69+
function isDiv(x: unknown): x is HTMLDivElement {
70+
return isNode(x) && x instanceof HTMLElement && x.tagName === 'DIV';
7271
}
7372

7473
export function isMount(
@@ -77,12 +76,12 @@ export function isMount(
7776
exact: boolean = false
7877
): x is Mount {
7978
return (
80-
isElement(x) &&
79+
isDiv(x) &&
8180
(value === undefined
8281
? x.matches(MOUNT_SELECTOR)
8382
: exact
84-
? x.matches(exactMountSelector(value))
85-
: x.matches(prefixedMountSelector(value)))
83+
? x.matches(exactMountSelector(value))
84+
: x.matches(prefixedMountSelector(value)))
8685
);
8786
}
8887

0 commit comments

Comments
 (0)