Re: [whatwg/dom] iterable declaration on NodeList is invalid (#284)

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...

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/284#issuecomment-236170427

Received on Friday, 29 July 2016 12:44:01 UTC