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

Preemptively error when required ES5 shim/shams are not available #1516

Merged
merged 1 commit into from
May 12, 2014
Merged

Preemptively error when required ES5 shim/shams are not available #1516

merged 1 commit into from
May 12, 2014

Conversation

syranide
Copy link
Contributor

As per @andreypopp's idea in #1507, here's an implementation.

I searched through the React code and discovered the list of required shim/shams in the docs is not up-to-date and have updated this PR accordingly (not the docs).

IE8 and really old (but still circulating) versions of most modern browsers are the troublemakers. So basically pretty much every browsers you'll run into has full support, except for a handful of visitors who lack most of them. http://kangax.github.io/compat-table/es5/

In order to keep an ecosystem of reusable components from second-guessing support (and us having to keep forgetting to update the list of required shims), I would recommend extending the list of required shims to include all ES5 shims (not shams): https://github.com/es-shims/es5-shim, it's not that many more and most are really useful.

__DEV__ only so didn't bother with size comparison.

@chenglou
Copy link
Contributor

👍

@sophiebits
Copy link
Collaborator

I was going to say you might check console too but I guess you won't be able to make much of a warning if it's absent.

@petehunt
Copy link
Contributor

Seems legit, gonna pull this in


for (var i in expectedFeatures) {
if (!expectedFeatures[i]) {
console.error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just sanity check: console.error() is available everywhere console is available, right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

95% sure yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petehunt Yes it is, even IE8 has it. While it is possible that some browser does not have it, it will still produce an appropriate error message (console.error not available) and we explicitly mention it next to the shims that the console.*-shim might be necessary. I could do (console.error || console.log) I guess to be on the really safe side, if you prefer (and add appropriate console.* methods to the list).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petehunt PS, you probably want to fb.me that link.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

petehunt added a commit that referenced this pull request May 12, 2014
Preemptively error when required ES5 shim/shams are not available
@petehunt petehunt merged commit e4f80f3 into facebook:master May 12, 2014
@syranide syranide deleted the es5err branch May 12, 2014 20:40
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

Successfully merging this pull request may close these issues.

5 participants