Open bzbarsky opened 8 years ago
The iterable declaration on DOMTokenList has the same problem.
It seems though that the iterator can never return null, right? Shouldn't we allow for the removal of nullability in that case?
That's not at all obvious from the IDL. The interface says it has an indexed getter that can return null; the iterator will use the indexed getter internally, so can return null too. The fact that the indexed getter can't actually return null in this case is buried in prose.
If the interface had:
Node? item(unsigned long index);
getter Node (unsigned long index);
then you could write iterator<Node>
without any qualms. Presumably you would define some shared operation that item
and the indexed getter both invoke.
Now maybe we should assume that anything with an indexed getter is lying about the getter being able to return null, because it's layering the getter on top of an accessor function which can in fact return null (but only calling it in cases when it can't). I'd have to do a really careful audit of all the 40-ish indexed getters in the platform before being willing to make that assumption, and it would be rather fragile if people add something new...
Maybe it's not worthwhile since we don't want new APIs to use getters, but I might have a look before changing this IDL.
NodeList has:
but http://heycam.github.io/webidl/#idl-iterable says:
In this case the types are different: one is
Node
and the other isNode?
.