Closed
Bug 1216751
Opened 9 years ago
Closed 9 years ago
provide forEach() method on iterable<> webidl interfaces
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla47
Tracking | Status | |
---|---|---|
firefox47 | --- | fixed |
People
(Reporter: bkelly, Assigned: bzbarsky)
Details
(Keywords: dev-doc-needed)
Attachments
(5 files, 4 obsolete files)
14.41 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
11.40 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
25.24 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
7.58 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
14.64 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
This part of the webidl spec suggests iterable<> interfaces should have a forEach() method:
http://heycam.github.io/webidl/#es-forEach
It seems there might be some issues with the spec, though.
I think we want to get this resolved, though, as most of the real world code I've seen using iterable on fetch Headers tries to use forEach().
Assignee | ||
Comment 1•9 years ago
|
||
Note to self: this spec needs a bit of work, since k and kValue are IDL values, not ES values, so they need conversion to ES values before the callback function can be invoked.... In implementation terms, we can either do that in bindings by hand or make the generated forEach method take as its first argument a callback type we synthesize which takes the right IDL arguments and let the binding infrastructure do most of the work.
Assignee | ||
Comment 2•9 years ago
|
||
Oh, and the current spec only makes sense for single-type iterables. And it seems to get the arguments backwards from every single other forEach in the world (which all have the value first, then the key).
I guess I'll try to write up a sane spec here....
Assignee | ||
Comment 3•9 years ago
|
||
Oh, and the third arg to forEach should be the this value; the callback this value should be undefined... At least if we want to match every iterable in ES6 that has forEach, as well as Chrome's Headers impl.
Assignee | ||
Comment 4•9 years ago
|
||
Though actually, do we want more arraylike semantics for forEach or more setlike? In particular, does a removal of a key at or before the point where forEach is called cause some keys to be skipped (like array) or not (like map/set)?
Chrome's Headers impl seems more arraylike in this case:
var h = new Headers;
h.append("a", "b")
h.append("c", "d")
h.append("e", "f")
h.forEach(function(...args) {
console.log(args);
h.delete("a");
});
logs:
["b", "a", Headers]
["f", "e", Headers]
I'm going to start a thread on public-script-coord, because this seems like the sort of thing that actually needs figuring out. :(
Assignee | ||
Comment 5•9 years ago
|
||
Comment 6•9 years ago
|
||
doc |
Added dev-doc-needed.
When this lands, we have to document forEach() for all occurences of iterator<>, currently FormData, Headers and URLSearchParam.
We will need to update: https://developer.mozilla.org/en-US/docs/MDN/Contribute/Howto/Write_an_API_reference/Information_contained_in_a_WebIDL_file#Pair_iterator
(removing the link to this bug and linking to FormData.forEach().
Keywords: dev-doc-needed
Comment 7•9 years ago
|
||
Cameron merged his spec changes for iterable<> yesterday:
https://github.com/heycam/webidl/commit/3c61abe1dda3c157ddf278b312540702277ecc00
/me assigning to Boris because he said he plans to fix this bug this week.
Assignee: nobody → bzbarsky
Assignee | ||
Comment 8•9 years ago
|
||
Attachment #8718136 -
Flags: review?(kyle)
Assignee | ||
Comment 9•9 years ago
|
||
Attachment #8718137 -
Flags: review?(kyle)
Assignee | ||
Comment 10•9 years ago
|
||
Attachment #8718138 -
Flags: review?(kyle)
Assignee | ||
Comment 11•9 years ago
|
||
Attachment #8718139 -
Flags: review?(kyle)
Assignee | ||
Comment 12•9 years ago
|
||
Attachment #8718140 -
Flags: review?(kyle)
Assignee | ||
Comment 13•9 years ago
|
||
Argh, this fails tests, because the spec is still wrong. In particular, https://github.com/heycam/webidl/issues/67 still needs to get fixed... Updated patches coming up.
Assignee | ||
Comment 14•9 years ago
|
||
Attachment #8718174 -
Flags: review?(kyle)
Assignee | ||
Updated•9 years ago
|
Attachment #8718138 -
Attachment is obsolete: true
Attachment #8718138 -
Flags: review?(kyle)
Assignee | ||
Comment 15•9 years ago
|
||
I think https://github.com/heycam/webidl/pull/90 should spec what I've implemented here.
Assignee | ||
Comment 16•9 years ago
|
||
Attachment #8718200 -
Flags: review?(kyle)
Assignee | ||
Updated•9 years ago
|
Attachment #8718136 -
Attachment is obsolete: true
Attachment #8718136 -
Flags: review?(kyle)
Assignee | ||
Comment 17•9 years ago
|
||
Attachment #8718208 -
Flags: review?(kyle)
Assignee | ||
Updated•9 years ago
|
Attachment #8718137 -
Attachment is obsolete: true
Attachment #8718137 -
Flags: review?(kyle)
Assignee | ||
Comment 18•9 years ago
|
||
Attachment #8718209 -
Flags: review?(kyle)
Assignee | ||
Updated•9 years ago
|
Attachment #8718140 -
Attachment is obsolete: true
Attachment #8718140 -
Flags: review?(kyle)
Updated•9 years ago
|
Attachment #8718200 -
Flags: review?(kyle) → review+
Updated•9 years ago
|
Attachment #8718208 -
Flags: review?(kyle) → review+
Updated•9 years ago
|
Attachment #8718174 -
Flags: review?(kyle) → review+
Updated•9 years ago
|
Attachment #8718139 -
Flags: review?(kyle) → review+
Updated•9 years ago
|
Attachment #8718209 -
Flags: review?(kyle) → review+
Comment 19•9 years ago
|
||
Everything looks good (and simpler/smaller than before!). Sorry for the review delay.
Comment 20•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/5fc801a87404
https://hg.mozilla.org/integration/mozilla-inbound/rev/efad6236ce3f
https://hg.mozilla.org/integration/mozilla-inbound/rev/62d0120fca7d
https://hg.mozilla.org/integration/mozilla-inbound/rev/3ad43093c8f4
https://hg.mozilla.org/integration/mozilla-inbound/rev/410ef34da2e7
Comment 21•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/5fc801a87404
https://hg.mozilla.org/mozilla-central/rev/efad6236ce3f
https://hg.mozilla.org/mozilla-central/rev/62d0120fca7d
https://hg.mozilla.org/mozilla-central/rev/3ad43093c8f4
https://hg.mozilla.org/mozilla-central/rev/410ef34da2e7
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox47:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Assignee | ||
Comment 22•9 years ago
|
||
Chris, are we going to need this on branches, or is trunk ok?
Flags: needinfo?(cpearce)
Comment 23•9 years ago
|
||
bz: At this stage, trunk is OK. We may want it uplifted later, I'll follow up if we need it uplifted.
Flags: needinfo?(cpearce)
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•