All files / components/src bullets.ts

100% Statements 15/15
100% Branches 5/5
100% Functions 5/5
100% Lines 11/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          62x 11x   62x 62x 62x     1x 6x 6x 6x 60x 14x    
/**
 * @module kung-fu/components
 */
 
function traverseList(elem: HTMLUListElement, level: number, order: string[]): void {
    if(level == 3) {
        level = 0;
    }
    elem.style.listStyleType = order[level];
    const children = elem.querySelectorAll(':scope > li > ul');
    Array.from(children).forEach((el: Element) => traverseList(el as HTMLUListElement, level + 1, order));
}
 
export const rotateListStyleType = (selector?: string, order?: string[]): void => {
    selector = selector || 'ul';
    order = order || ['disc', 'circle', 'square'];
    const uls: NodeListOf<HTMLUListElement> = document.querySelectorAll(selector);
    const arr: HTMLUListElement[] = Array.from(uls).filter((e: HTMLUListElement) => e.closest('li') == null);
    arr.forEach((elem: HTMLUListElement): void => traverseList(elem, 0, order as string[]));
};