iamdustan / smoothscroll

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

Why prefer HTMLElement? #126

Open saschanaz opened 6 years ago

saschanaz commented 6 years ago

I found that the code prefers HTMLElement to Element:

https://github.com/iamdustan/smoothscroll/blob/8a19e81e17ba39efed1c8b48c7976e3702238105/src/smoothscroll.js#L18

...and causes adding scrollIntoView() to HTMLElement instead of Element. What was the reasoning there?

iamdustan commented 5 years ago

:man_shrugging: do you have an argument or reasoning to change it that is currently broken?

saschanaz commented 5 years ago

Recalling what was the problem... Ah, it caused feature detection to falsely fail, as the code expected Element.prototype.scrollIntoView to exist.

elliottregan commented 5 years ago

That's a good point. MDN has .scrollIntoView() listed under Element, which is backed up by the CSSOM View Module spec.

Looks like it should prefer Element over HTMLElement. I haven't tested this with other implementations of Element, like SVGElement, but it sounds like it should work in browsers that support the extension, and so this polyfill should allow that, as well.

acontreras89 commented 3 years ago

Possibly related to #153