( node: Element | HTMLElement | SVGImageElement, instance: T, )
| 243 | } |
| 244 | |
| 245 | export const isInstanceOfElement = < |
| 246 | T extends typeof Element | typeof HTMLElement | typeof SVGImageElement, |
| 247 | >( |
| 248 | node: Element | HTMLElement | SVGImageElement, |
| 249 | instance: T, |
| 250 | ): node is T['prototype'] => { |
| 251 | if (node instanceof instance) return true |
| 252 | |
| 253 | const nodePrototype = Object.getPrototypeOf(node) |
| 254 | |
| 255 | if (nodePrototype === null) return false |
| 256 | |
| 257 | return ( |
| 258 | nodePrototype.constructor.name === instance.name || |
| 259 | isInstanceOfElement(nodePrototype, instance) |
| 260 | ) |
| 261 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…