W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2012

Re: An iterable DOM

From: Cameron McCormack <cam@mcc.id.au>
Date: Thu, 28 Jun 2012 12:30:37 +1000
Message-ID: <4FEBC1CD.6080100@mcc.id.au>
To: Jason Orendorff <jason.orendorff@gmail.com>
CC: public-script-coord <public-script-coord@w3.org>
I've added iterators to the spec:

* Interfaces that have an indexed property getter automatically get an
   iterator() method on their prototype that returns an array index
   iterator (just like Array.prototype.iterator would).

* Interfaces can be declared to have a custom iterator (which would
   override the automatic indexed property getter one if it would
   otherwise have one), like this:

     interface NodeList {
       Node iterator;

   You then define in prose what the "iterator behavior" is for a
   NodeList, which given some state defines what is the next value
   to return.

   There exists an "iterator prototype object" for each interface that
   declares an iterator in this way -- so here there would be a
   NodeListIterator prototype object, which is the [[Prototype]]
   for objects returned from NodeList.prototype.iterator.

* You can declare that the iterator object implements a particular

     interface NodeList {
       Node iterator = NodeIterator;

   in which case the iterator object interface must be declared like

     interface NodeIterator {
       Node iterator object;

   When this form is used, you define in prose how to "create an iterator
   object" for a NodeList (i.e. how you would create a NodeIterator
   object that knows it is iterating over a particular NodeList) and also
   what the "iterator object behavior" is for NodeIterator, which given
   the NodeIterator object as the state, what the next value to return

There are examples in the spec of these prose definitions that would be 


Received on Thursday, 28 June 2012 02:31:11 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:06 UTC