Dom: Iterable NamedNodeMap

Created on 21 May 2018  路  3Comments  路  Source: whatwg/dom

Based on Chrome, FF implementations NamedNodeMap can be iterable([Symbol.iterator])

Chrome

FF

for (const attr of document.body.attributes) {
    console.log(attr);
}

however, in the spec, there is no mention about that. For instance DOMTokenList has iterable<DOMString>.

Most helpful comment

Specifically https://heycam.github.io/webidl/#es-iterators (since I had that on the clipboard for a reply before domenic's comment landed)

All 3 comments

Per Web IDL, any indexed getter and length property makes you automatically get [Symbol.iterator].

Specifically https://heycam.github.io/webidl/#es-iterators (since I had that on the clipboard for a reply before domenic's comment landed)

@domenic @inexorabletash thanks for the clarification.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ginden picture Ginden  路  4Comments

domenic picture domenic  路  8Comments

annevk picture annevk  路  9Comments

Netmosfera picture Netmosfera  路  6Comments

domenic picture domenic  路  12Comments