Bug 131698
Summary: | Simple ES6 feature: Array.from | ||
---|---|---|---|
Product: | WebKit | Reporter: | Oliver Hunt <oliver> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | caitp, ggaren, graouts, m.goleb+bugzilla, webkit-bug-importer |
Priority: | P2 | Keywords: | EasyFix, InRadar |
Version: | 528+ (Nightly build) | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Oliver Hunt
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-22.1.2.1
Should be doable in builtin JS
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/16625961>
Antoine Quint
Dupe of 130966, landed in http://trac.webkit.org/changeset/167797.
*** This bug has been marked as a duplicate of bug 130966 ***
Antoine Quint
Wrong bug, sorry!
Caitlin Potter (:caitp)
This bug should be simple, but is at least partially blocked on iterators being available.
Oliver Hunt
We support for-of on all currently iterable types, as well as the spread operator so should be either
Return [...arguments]
Or
Return [...source]
I can't recall spec of the top of my head
Caitlin Potter (:caitp)
You're correct, for-of and the spread operator are supported for certain types (although strings appear to not be iterable yet in JSC).
However, iterator methods seem to be attached via private properties / internal slots, rather than using the well-known symbol @@iterator.
The Array.from algorithm uses `GetMethod(items, @@iterator)` to determine whether or not it can use the from-iterable path or the from-array-like path, so an implementation is still sort of blocked on that (or at least blocked on exposing a getter for the private iterator properties to JS builtins, if it is to be implemented in JS).
Oliver Hunt
I would actually say that the hardest part here will be updating the builtins generation logic to support constructor/static functions.
The subsequent logic would be to expose (as a private global) the Symbol object, with @@iterator attached. (You'd still need to use for-of. Our internal iterator implementation doesn't match spec behaviour for reasons best summed up as "performance")
Oliver Hunt
note builtin JS can do magical things - look at the js files in builtins/
Geoffrey Garen
This is done.
Geoffrey Garen
http://trac.webkit.org/changeset/183357