isElementType.Function.isElementType - GyldendalDigital/kobber GitHub Wiki
@gyldendal/kobber-components / isElementType / isElementType
isElementType<
T
>(value
,ElementClass
):value is T
Defined in: packages/kobber-components/src/utils/isElementType.ts:25
Type guard for narrowing an element's type.
• T extends Element
undefined
| null
| Element
() => Element
Element
value is T
Example using a native element
if(isElementType<HTMLAnchorElement>(myElement, HTMLAnchorElement)) {
console.log(myElement.href);
}
Example using a web component
if(isElementType<MyWebComponent>(myElement, MyWebComponent)) {
console.log(myElement.customProperty);
}