tbranyen / hyperlist

A performant virtual scrolling list utility capable of rendering millions of rows
Other
448 stars 45 forks source link

Use element.classList if available to add the rowClassName to the item #40

Closed x11x closed 7 years ago

x11x commented 7 years ago

This is a minor change to use Element.classList.add DOM method if its available. This takes care of preserving existing class names and not duplicating the name if its already in the classlist. The main reason I need this is I noticed that when reusing elements in the config.generate function, the class name ('vrow') is just appended. The element ended up with class=' vrow vrow vrow', with the duplicated list growing each time generate was called. Note that if classList is not available, the fallback is identical to the current behaviour. Not sure if its worth it to do proper string manipulation to make sure class name is not repeated.

tbranyen commented 7 years ago

Thanks for this, looks like it was approved a week ago (was on vacation). Mergin'