htmx
htmx copied to clipboard
class-tools extension will only handle the last operation defined in `classes`
Due to how closures work, when the function defined in setTimeout is called, the classOperation will be the last one in the for loop.
https://github.com/bigskysoftware/htmx/blob/v1.7.0/src/ext/class-tools.js#L52
So having foo add:1, bar remove:2 => foo will never be added.
The solution is to move the calls to setTimeout in a function that will take classOperation as an argument.
cf https://medium.com/@axionoso/watch-out-when-using-settimeout-in-for-loop-js-75a047e27a5f
great catch!
would you mind putting together a pull request for this?