• Select the elements matching the keys in applyMap and run the functions given by the values over them. This eliminates the many calls to querySelectorAll, which is quite verbose.

    Without the third argument (asComponents), all selected elements are passed to the functions at once. With the argument given as a truthy value, the elements are passed one by one, so that the behavior is almost like that of web components.

    Parameters

    • applyMap: ApplyMap
    • Optional containerElement: HTMLElement
    • Optional asComponent: number | boolean
    • Optional firstOnly: number | boolean

    Returns void

    Example

    apply({
    main: main => {
    const newContent = [...range(101, 120)].map(i => `My index is now ${i}`);
    const lastChildren = Array.from(main.children).map(c => c.lastElementChild);
    set(lastChildren, {textContent: newContent});
    }
    });