type tag = keyof HTMLElementTagNameMap ; export function isElementType < T extends tag , P extends { [ k ] : unknown ; } | undefined = undefined > ( element , tag , props ? ) { if ( element . namespaceURI && element . namespaceURI !== 'http://www.w3.org/1999/xhtml' ) { return false ; } tag = Array . isArray ( tag ) ? tag : [ tag ] ; if ( ! tag . includes ( element . tagName . toLowerCase ( ) as T ) ) { return false ; } if ( props ) { return Object . entries ( props as NonNullable < P > ) . every ( ( [ k , v ] ) => element [ k as keyof Element ] === v ) ; } return true ; }