Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which / are polyfills are needed? #585

Closed
screendriver opened this issue Mar 14, 2017 · 12 comments
Closed

Which / are polyfills are needed? #585

screendriver opened this issue Mar 14, 2017 · 12 comments

Comments

@screendriver
Copy link

Are there any polyfills that are needed for older browser to work with preact?

For example Inferno needs this ones.

@gdorsi
Copy link

gdorsi commented Mar 14, 2017

I use es5-shim, es5-sham & addEventListner polyfill and it works for me.

@screendriver
Copy link
Author

Hmm ok. The reason for the question is that I don't want to include everything from core-js or es5-shim. At the moment I only include what's really needed because I want my bundle as small as possible. For example core-js/es6/promise, core-js/es6/map, core-js/es6/weak-map, core-js/fn/object/assign and core-js/fn/object/keys

@gdorsi
Copy link

gdorsi commented Mar 14, 2017

I've made a rapid check on the codebase and seems that addEventListener is the only polyfill needed

@screendriver
Copy link
Author

Really? 😳 I expected more. That would be awesome if preact does not require any more polyfills 💃

@developit
Copy link
Member

@screendriver hmm - what older browsers? Preact supports IE9+ with no polyfills at all.

@screendriver
Copy link
Author

Bam! That's all I wanted to hear 💃 Thank you very much @developit

@developit
Copy link
Member

developit commented Mar 14, 2017

Awesome :) For reference, here's the list of browser APIs Preact relies on:

  • It will use Promise only if available, falling back to setTimeout(0)
  • DOM APIs used are very minimal DOM core 1 / 2:
    • document.createElement() and document.createTextNode()
    • Text.prototype.nodeValue
    • From Element.prototype:
      • .attributes NodeList
      • .setAttribute(), .getAttribute(), .removeAttribute()
      • .appendChild(), .insertBefore(), .replaceChild()

If you use SVG, createElementNS() and (get|set|remove)AttributeNS() are used.

All of these are actually supported way back beyond IE9, but IE8 and prior includes an issue where you cannot define arbitrary properties on Text nodes (explained in #537)

I could definitely see a future where, given that there are hacks to fix #537 already being worked on, Preact would support IE7+ without polyfills.

@screendriver
Copy link
Author

👍

That should be either in the README or on https://preactjs.com 😉

@developit
Copy link
Member

Totally - we have a browser support page here but it's woefully poor at explaining this.

@screendriver
Copy link
Author

Ah I see. Thank you for your help. Hopefully the page will be updated in the future at some point.

@joshua-mason
Copy link

screendriver hmm - what older browsers? Preact supports IE9+ with no polyfills at all.

@developit just wanted to check if this is still the case, or if there have been any added since this was discussed?

@developit
Copy link
Member

@joshua-mason the current version of Preact still works perfectly in IE9.

Screenshot 2023-03-23 at 3 14 37 PM

We will likely begin requiring some very minimal polyfills for IE9-11 starting in Preact 11 though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants