All files / roosterjs-content-model-dom/lib/domUtils isElementOfType.ts

100% Statements 2/2
75% Branches 6/8
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13            1x       4662x    
/**
 * Check if the given element is of the type that we are checking according to its tag name
 * @param element The element to check
 * @param tag The HTML tag name to check
 * @returns True if the element has the given tag, otherwise false
 */
export function isElementOfType<Tag extends keyof HTMLElementTagNameMap>(
    element: HTMLElement,
    tag: Tag
): element is HTMLElementTagNameMap[Tag] {
    return element?.tagName?.toLocaleLowerCase() == tag;
}