Changed element references in library from HTMLElement/Nodelist to a functional argument