mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-28 05:21:18 +00:00

* Update parseInterval to handle "0" correctly When a parameter like "0ms" is passed in to parseInterval it gets parsed to 0. Previously this would result in a return value of "undefined" because 0 is falsy and thus the `return 0 || undefined` statements return undefined. The purpose of the form `parseFloat(str) || undefined` was to return "undefined" if parseFloat failed (parseFloat returns NaN, a falsy value, if it can't parse its argument). Unfortunately, as mentioned, parseFloat can also succeed and return a falsy value -- when the argument is "0" (or "0.0", etc.). So the new code, rather than depending on the falsiness of the result of parseFloat, explicitly checks for a NaN. * Adds some semicolons Adds some semicolons to parseInterval (and tests) for consistency. * Add one more parseInterval test for "0" Adds test test to make sure parseInterval works on "0". * Adds functional tests for every, swap, settle, throttle, and delay * Explcitly check that setTimeout values are > 0 These values come from user settings that are read from parseInterval, so they could be a number or undefined. If the value being checked is > 0 setTimeout will be called with some associated function. If the value is 0 or 'undefined' the associated function will be called immediately ('undefined' is not greater than 0). * Change '!== undefined' to '> 0' `pollInterval !== undefined` is a subtly different conditional than just `pollInterval` or `pollInterval > 0` (which are equivalent). Changes the conditional to `pollInterval > 0` so as to not change the behavior but also be more explicit in the test.