[whatwg/webidl] Maplike/setlike iterators shouldn't use MapIteratorPrototype/etc (Issue #1142)

#1138 switched maplike/setlike interfaces to use Infra maps/sets, and as part of that had to redefine some text out of the ES spec, notably reusing the language of [CreateMapIterator](https://tc39.es/ecma262/#sec-createmapiterator) and subbing in a new closure that worked on the infra map/set rather than the ES Map/Set it previously used.

Per discussion with @bakkot and @ljharb, the ES spec doesn't, in fact, intend for this to be pluggable in quite this way; notably, apparently it's bad to create an iterator inheriting from %MapIteratorPrototype% but with a different iteration behavior. (CreateIteratorFromClosure *looked* pluggable, but in reality the second and third arguments should be unique per call site.)

They suggest instead that I should define a new prototype object, descended from %IteratorPrototype%, and define its methods itself; this is very short and simple to do, as shown in [the definition of %MapIteratorPrototype%](https://tc39.es/ecma262/#sec-%mapiteratorprototype%-object). (I shouldn't just use %GeneratorPrototype%, like a userland generator, because then I have to worry about `.return()`, which I don't want to worry about.)

Patch incoming.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1142
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1142@github.com>

Received on Thursday, 5 May 2022 19:51:32 UTC