Closed Dan503 closed 4 years ago
Hi @Dan503,
I'm facing similar problems when using the polyfill with MS Edge 18. Have you checked if your fix could also help here? It is probably the same problem.
@mkScript I haven't checked MS Edge 18 but I wouldn't be surprised if it has the same problems as IE since IE11 is just the grandfather of MS Edge.
@mkScript if you want to get the fix right now without waiting, copy the node_modules/seamless-scroll-polyfill/dist/esm
folder into your project source folder and save the files into git. Delete all the .map
files, you don't need them. (I'm assuming your project is using ES6 imports or Typescript).
Make the changes outlined in this PR manually, then when importing seamless-scroll-polyfill, import from your version in the source folder rather than from node_modules.
sorry for the late reply.
What about polyfill the HTMLElement, SVGElement, and Element at the same time?
Ok, I can make that change. It will probably mean making a helper function to apply to all 3 every time rather than repeating code every time.
I've modified all three now.
In Element.scroll.ts
I'm still only checking HTMLElement.prototype
since it is checking for existence rather than modifying the prototype. Checking for only HTMLElement.prototype
should be fine I think.
LGTM
Thanks for merging 😊
Don't forget to publish a new version to npm though.
IE11 fix: Swapping
Element
prototype withHTMLElement
For some reason, IE11 doesn't respond to prototype modifications done to the
Element
prototype.However it does respond to changes to the
HTMLElement
prototype.IE11 fix: Adding
supportsScrollBehavior
check toelem.scrollIntoView()
getOriginalFunc
functionIE11 has partial support for
element.scrollIntoView()
.Since IE11 recognizes that the
scrollIntoView
function on elements exists, it skips applying the polyfill and uses native code instead.This change ensures that the browser will only use native code under two conditions:
"scrollBehavior"
functionality.If either of those conditions are false, it will use the polyfill instead.