magic-akari / seamless-scroll-polyfill

Scroll Behavior polyfill
https://www.npmjs.com/package/seamless-scroll-polyfill
MIT License
159 stars 12 forks source link

TypeError: Can only call Performance.now on instances of Performance #81

Closed stami closed 4 years ago

stami commented 4 years ago

Hi, the latest version breaks on Safari browsers, and probably all others where the polyfill is used.

In the last commit, the optional chaining will probably be transpiled to some equivalent of the following example, that can be replicated in Safari console:

> performance.now()
// prints out the value

const myNow = performance.now
myNow()
// TypeError: Can only call Performance.now on instances of Performance

It crashes also on Chrome console with TypeError: Illegal invocation, but the polyfill won't get applied on Chrome...

The original pull request line runs fine as is:

(performance && performance.now ? performance : Date).now();
magic-akari commented 4 years ago

My bad. Thanks.