All files dom-extensions.ts

36.36% Statements 4/11
18.18% Branches 2/11
50% Functions 1/2
36.36% Lines 4/11

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 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29      1x 1x 1x                                       1x      
/**
 * Check if an element is a descendent of another element.
 */
export function isDescendant(parent: (HTMLElement | Element), child: (HTMLElement | Element)): boolean {
    Eif (!parent || !child) {
        return false;
    }
 
    let node: Node = child.parentNode;
 
    while (!!node) {
        if (node === parent) {
            return true;
        }
 
        node = node.parentNode;
    }
 
    return false;
}
 
/**
 * Gets the numeric key code associated with a keyboard event. This method is for use with DOM level 3 events
 * that still use the deprecated keyCode property.
 */
export const getKeyCode: (event: KeyboardEvent) => number = (event: KeyboardEvent): number => {
    return (event == null) ? null : event.which || event.keyCode || event.charCode;
};