Skip to content

Commit fcac4a1

Browse files
author
Kai
authored
feat: add .is on components (#68)
2 parents 439aa2a + 2025153 commit fcac4a1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ export class Component<T extends HTMLElement = HTMLElement> extends ElementCompo
8989
return new Component<T>(element);
9090
}
9191

92+
/**
93+
* Test whether the element would be selected by the specified
94+
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors CSS selector}, or group of CSS selectors.
95+
* @param selectors
96+
*/
97+
public is(selectors: string): boolean {
98+
return this.node.matches(selectors);
99+
}
100+
92101
/**
93102
* Set style property
94103
* @param name Property name

0 commit comments

Comments
 (0)