delayed-scroll-restoration-polyfill icon indicating copy to clipboard operation
delayed-scroll-restoration-polyfill copied to clipboard

IE11 Compatibility

Open jmaikeru opened this issue 7 years ago • 7 comments

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?

jmaikeru avatar Aug 15 '17 01:08 jmaikeru

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!

trotzig avatar Aug 15 '17 20:08 trotzig

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:

  1. Include the polyfill, or
  2. Use the function locally, or
  3. Update docs and call it a dependency for IE11

jmaikeru avatar Aug 16 '17 05:08 jmaikeru

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.

trotzig avatar Aug 16 '17 15:08 trotzig

So, is this compatible with IE11?

kallebornemark avatar Jan 15 '19 08:01 kallebornemark

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 😬

jmaikeru avatar Jan 15 '19 10:01 jmaikeru

Thank you @jmaikeru!

kallebornemark avatar Jan 15 '19 14:01 kallebornemark

Created a PR https://github.com/janpaul123/delayed-scroll-restoration-polyfill/pull/9

Thanks, @jmaikeru!

juliaqiuxy avatar Oct 18 '19 16:10 juliaqiuxy