HubSpot / odometer

Smoothly transitions numbers with ease. #hubspot-open-source
http://github.hubspot.com/odometer/docs/welcome
MIT License
7.31k stars 716 forks source link

Validate duration option #103

Open marfire opened 9 years ago

marfire commented 9 years ago

I had a bug in my code that caused the duration option passed to the constructor to be negative.

My fault, of course. But the consequence was that animateSlide() went into an infinite loop and crashed the tab / browser! (The details don't really matter, but when duration is negative, MAX_VALUES is negative, which causes the subsample check to fail and the loop boundary checks to have the wrong sign.)

Given such a severe and hard-to-debug consequence, I think it would be a good idea to validate the value of duration in the constructor. (And I note that you're already validating format.)