LeaVerou / multirange

A tiny polyfill for HTML5 multi-handle sliders
http://projects.verou.me/multirange/
MIT License
605 stars 82 forks source link

moved detection outside loop to avoid unneccessary DOM access in capa… #1

Closed codepo8 closed 8 years ago

codepo8 commented 8 years ago

…ble browsers

Seems less wasteful.

LeaVerou commented 8 years ago

The reason I didn't do it that way to begin with is that multirange() still needs to be defined, otherwise the JS will error if people call the function manually to cater for dynamically added sliders. Also, the detection itself is outside the loop, only its cached result is checked in multirange().

codepo8 commented 8 years ago

Makes sense, but needs some docs that this is an option. Especially that you need to call it with the input element as the parameter.

Yes, the check is outside, I considered it a sensible move to avoid the loop over all elements, but you're right, this makes the method not reusable.

LeaVerou commented 8 years ago

It is in the docs :)

From the API section:

JS: Use the multirange(element) function to process sliders added to the page later.