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

feature detects for ES6 Array, Math, Number, Object, String; for #1170 #1269

Merged
merged 1 commit into from
Apr 2, 2014
Merged

feature detects for ES6 Array, Math, Number, Object, String; for #1170 #1269

merged 1 commit into from
Apr 2, 2014

Conversation

jokeyrhyme
Copy link
Contributor

for #1170

}
!*/
/* DOC
Check if browser implements ECMAScript 5 Array per specification.
Copy link
Member

Choose a reason for hiding this comment

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

do you mean ECMAScript 6 Array?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix this in a second. :)

@jokeyrhyme
Copy link
Contributor Author

I noticed that there's a separate feature-detect for String.prototype.contains by @robertkowalski

I have left it in place. However, it's possible that it makes sense to remove it, as the es6string detect covers it as well.

@jokeyrhyme
Copy link
Contributor Author

I squashed and force pushed. The typo and the unwrapping of unnecessary functions has been done.

@patrickkettner
Copy link
Member

bravo, sir. very well done.

I am a bit confused as to the utility of this, though. Why would someone want to know that all properties exist (rather than a specific one?)

@jokeyrhyme
Copy link
Contributor Author

@patrickkettner I'm just following the pattern of a previous pull request I got through for the ES5 tests: #901

It seemed okay back then to test for them in type-specific batches.

@patrickkettner
Copy link
Member

@jokeyrhyme - totally get that, it was more of a topic-of-discussion for @stucox, @ryanseddon, @paulirish, yourself, and anyone else who would like to pitch in an opinion.

@stucox
Copy link
Member

stucox commented Mar 18, 2014

Separate detects for every feature would result in LOADS of new detects — and you'd have to include loads to know whether or not to load a shim (which you may well not want to download if it isn't needed). There's both a performance & maintenance overhead in having many separate detects instead of a few broader ones.

I haven't really looked into the available ES6 shims, but for ES5 it was evident that grouping them like this was a good compromise, meaning only a couple of detects were needed to decide which shim/sham may be needed — while not tying Modernizr to a specific set of shims.

@stucox
Copy link
Member

stucox commented Mar 18, 2014

@jokeyrhyme How do we expect these to evolve as the drafts change? As you highlighted on the other thread, a few things are still in flux. While we want to keep current, it might be odd if we release a detect which changes what it considers to be a “compliant” implementation too frequently.

We could attach a warning that this is a new spec in flux and our detect may change accordingly?

@jokeyrhyme
Copy link
Contributor Author

We could always hold off merging this until ES6 goes gold. Also, this won't be in the wild until Modernizr v3 at the earliest if you do merge. What's that timeframe versus ES6 timeframe looking like?

Number.prototype.clz is the only method that has moved in months, and there are a handful of additional properties that we'll need to add to the "es6object" test in a month or so. The methods on the basic types seem to be the most solid parts of ES6 at this point (with Firefox and Chrome actually implementing a good chunk of them in their stable branches).

Anyone trying to detect ES6 right now should know that ES6 itself isn't finished, so our feature detects can't be considered final. If we have an "experimental" flag, that would be great. Is it worth raising that as a separate issue?

An experimental flag might even allow us to avoid future issues like the "flexbox" and "flexwrap" detects, which really should have been merged but couldn't be because of downstream compatibility concerns.

@stucox
Copy link
Member

stucox commented Mar 19, 2014

I'm 1 free weekend away from being ready to release a v3 beta.

I don't think we need an "experimental" flag, that's kind of what warnings is for (and was actually one of the proposed use cases for it when we defined the metadata structure).

@jokeyrhyme
Copy link
Contributor Author

@stucox my bad. I didn't realise there actually already was a warnings metadata field. I'll set this appropriately, hopefully within the next 24 hours.

@jokeyrhyme
Copy link
Contributor Author

I just updated the notes and warnings metadata fields as suggested.

Let me know if there is anything else found wanting. :)

@stucox
Copy link
Member

stucox commented Mar 24, 2014

Excellent stuff.

This looks good to me then. What say you, @patrickkettner? Happy with this approach?

@patrickkettner
Copy link
Member

+1

only nit is I think detection should be detect, based on the last what-we-call-the-detect-tests-thingies conversation.

@jokeyrhyme
Copy link
Contributor Author

@patrickkettner done!

@patrickkettner
Copy link
Member

I'm +1

@jokeyrhyme
Copy link
Contributor Author

Just one last question: do you think I ought to included sub-class tests for the built-ins in this set of detects?
https://github.com/lukehoban/es6features#subclassable-built-ins

@patrickkettner
Copy link
Member

sounds useful

@stucox
Copy link
Member

stucox commented Mar 26, 2014

Maybe that should be a separate detect (or at least a separate PR). Is it reasonable to assume a browser would make all of these built-ins subclassable at the same time?

@jokeyrhyme
Copy link
Contributor Author

Perhaps. As I discuss over in the ticket, detecting subclassable would possibly rely on either the es5object detect or an as-yet-unwritten detect for ES6 classes.

It's probably best to tackle these in a separate detect.

@stucox
Copy link
Member

stucox commented Mar 27, 2014

I think we’re looking good here then. Unless we want to change all of the clauses to use 'clz32' in Math etc… but that’d make it seriously verbose for this many checks.

Any properties here for which we can imagine some implementation might throw an error for when accessed, rather than just being undefined if not supported? Or any which could possibly have a falsy value when they are supported?

@jokeyrhyme
Copy link
Contributor Author

@stucox We have the warnings in place. Does this not give us license to ask for forgiveness later? :)
These detects should be safe, from my reading of the drafts. I do expect they'll need some gentle tweaking once ES6 goes gold, anyway.

@stucox
Copy link
Member

stucox commented Apr 2, 2014

Yep, sounds like a plan.

Thanks dude 👍

stucox pushed a commit that referenced this pull request Apr 2, 2014
feature detects for ES6 Array, Math, Number, Object, String; for #1170
@stucox stucox merged commit 3b56e73 into Modernizr:master Apr 2, 2014
patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this pull request Feb 22, 2015
feature detects for ES6 Array, Math, Number, Object, String; for Modernizr#1170
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.

3 participants