Optional
containerElement: HTMLElementOptional
asComponent: number | booleanOptional
firstOnly: number | booleanapply({
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});
}
});
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.