iamdustan / smoothscroll

Scroll Behavior polyfill
http://iamdustan.com/smoothscroll/
MIT License
3.85k stars 339 forks source link

null as the first argument causing a TypeError #161

Open udayanshevade opened 4 years ago

udayanshevade commented 4 years ago

Been relying on this great polyfill for a while, so thank you!

Just started seeing a TypeError when null is passed in as the first argument to window.scrollTo:

Uncaught TypeError: Cannot read property 'left' of null

Although null is accommodated in the utility here, it needs to be subsequently handled here once shouldBailOut(arguments[0]) evaluates to true.

I have a branch adding a few quick checks wherever the original scroll functions are called. Please let me know if this looks like it might be worth fixing. If so, I have a PR ready here #160.

Additional context: ran into this issue while using both the polyfill as well as CodeMirror, which calls window.scrollTo here.