Closed Bug 1215925 Opened 9 years ago Closed 8 years ago

Implement DOMTokenList iterable<>

Categories

(Core :: DOM: Core & HTML, defect)

40 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1290636

People

(Reporter: crimsteam, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0 Build ID: 20151014143721 Steps to reproduce: In DOM this interface is iterable: https://dom.spec.whatwg.org/#domtokenlist Fast test: <script> alert (document.documentElement.classList.values()); // [object Iterator] </script> DOMSettableTokenList inherit from DOMTokenList, so should be iterable too. Chrome (stable) support it for both, but Firefox (nightly) still not.
Component: General → DOM
> In DOM this interface is iterable: Hmm. Why? Do we actually want values() and company here, or just for..of iterability?
Flags: needinfo?(annevk)
Depends on: 1085293
I guess this came up in https://www.w3.org/Bugs/Public/show_bug.cgi?id=23212 too. I still think the fact that using iterable<> here means that the class doesn't use the normal Array iterator is kinda busted; I think we should fix that in the spec (and in our iterable<> implementation). But there's another problem here, actually. Normal single-type iterables basically have keys() and values() produce the same thing and entries() produce pairs of the same thing, just like Set and setlike . And for..of iteration uses values(). The spec hasn't been updated to this yet, but that's what we've just implemented; the fact that there are single-type iterators already shipping in Blink with behavior not compatible with that is ... unfortunate. So in the DOMTokenList case, what that would mean is that keys() would return the strings, not the indices. I think that's fairly counterintuitive. I guess I'll follow up in https://www.w3.org/Bugs/Public/show_bug.cgi?id=26985 with a possible spec proposal for this stuff...
Flags: needinfo?(kyle)
Flags: needinfo?(cam)
Yes, I think we did want values() and company, per ECMAScript Set.
Flags: needinfo?(annevk)
Note the spec discussion continues unabated, with the latest proposals including removing the iterable declaration from this interface. Going to wait for the spec to stabilize before messing with this.
Flags: needinfo?(kyle)
Marking as dup of bug 1290636 and clearing heycam's ni? since the DOMTokenList stuff is being implemented there.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Flags: needinfo?(cam)
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.