delayed-scroll-restoration-polyfill
delayed-scroll-restoration-polyfill copied to clipboard
IE11 Compatibility
Transpiled this to EC5- works just fine aside from needing a polyfill for Number.isFinite- also needed to change the scrollX/Y properties to pageOffsetX/Y- similar to https://github.com/ReactTraining/react-router/issues/605
Should I submit a pull request?
You mean ES5, right? The shipped npm module is already transpiled, but you're right that we need the polyfill and the x/y properties.
We'd be very happy for a PR!
Ah, yes, turns out I can't type. I grabbed the raw .js from Github instead of installing the node module.
Will cook something up- what would your preferred approach be to dealing with Number.isFinite?
Could either:
- Include the polyfill, or
- Use the function locally, or
- Update docs and call it a dependency for IE11
I think we should just switch to isFinite
. It doesn't check that the argument is a number, but it works across all browsers. And we know that we're always passing in numbers.
So, is this compatible with IE11?
Yes and no.
Change lines 11-12 in index.es6.js
to:
__scrollX: window.pageXOffset || document.documentElement.scrollLeft,
__scrollY: window.pageYOffset || document.documentElement.scrollTop,
and 66-67 in the same file to:
isFinite(state.__scrollX) &&
isFinite(state.__scrollY)) {
Those are IE11 compatible.
I never did submit a PR 😬
Thank you @jmaikeru!
Created a PR https://github.com/janpaul123/delayed-scroll-restoration-polyfill/pull/9
Thanks, @jmaikeru!