[heycam/webidl] Add dedicated IDL syntax for indexed property getters (#584)

https://github.com/w3ctag/design-reviews/issues/229#issuecomment-424390065 -

> It took some doing, but we eventually discovered that it’s possible to iterate over the NamedNodeMap using for..of, but we had to discover this through an obscure part of WebIDL. Would be nice if this could be made more obvious? E.g., an @@iterator directive..

Specifically: https://heycam.github.io/webidl/#es-iterator - an interface with an indexed property getter and an integer-typed length attribute gets @@iterator applied.

This is subtle enough in the spec that it comes up frequently, e.g. as feature requests for specs that already support it. I'm guilty of missing it at least once myself and filing a bug.

One approach would be to simply have it be best practice for spec authors to annotate their WebIDL:

```webidl
  readonly attribute unsigned long length;
  getter Attr? item(unsigned long index);
  // @@iterator is implicitly provided c/o the above attribute/getter
```

Alternately, we could invent a WebIDL syntax for this, e.g.

```webidl
  indexedIterable<Attr>;
```
... which desugars into the above, requiring the same prose. But then a `setter` (if any) looks weird.



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

Received on Tuesday, 25 September 2018 19:21:51 UTC