Check for class' existance before removal : needed ?
Closed this issue · 2 comments
Golmote commented
Is the hasClass check really needed in removeClass ?
toddmotto commented
Not sure what the performance implications would be by removing it, i.e. would it be faster to simply check if the class exists and return, or pointlessly call the APIs if it's not?
toddmotto commented
I've updated the API so that classList handles itself, and the if statements are used for the fallback only. As classList will take care of those steps under the hood it makes sense to move the safety checks to the fallbacks only. With remove class, I think it'd be better to keep the if statement to avoid needlessly parsing the entire class string with RegExp and replacing things unnecessarily.