Skip to content

Commit f258e5d

Browse files
committed
Remove incorrect claim that node lists aren't iterable
Closes marijnh#529
1 parent fe5c717 commit f258e5d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

14_dom.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ it has found one:
221221
```{sandbox: "homepage"}
222222
function talksAbout(node, string) {
223223
if (node.nodeType == Node.ELEMENT_NODE) {
224-
for (let i = 0; i < node.childNodes.length; i++) {
225-
if (talksAbout(node.childNodes[i], string)) {
224+
for (let child of node.childNodes) {
225+
if (talksAbout(child, string)) {
226226
return true;
227227
}
228228
}
@@ -236,12 +236,6 @@ console.log(talksAbout(document.body, "book"));
236236
// → true
237237
```
238238

239-
{{index "childNodes property", "array-like object", "Array.from function"}}
240-
241-
Because `childNodes` is not a real array, we cannot loop over it with
242-
`for`/`of` and have to run over the index range using a regular `for`
243-
loop or use `Array.from`.
244-
245239
{{index "nodeValue property"}}
246240

247241
The `nodeValue` property of a text node holds the string of text that

html/errata.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ <h2>Chapter 11</h2>
6767

6868
<h2>Chapter 14</h2>
6969

70+
<p><strong>Page 231</strong> <em>Moving Through the Tree</em>: Below
71+
the code example, the text claims
72+
that <code>for</code>/<code>of</code> loops don't work on DOM child
73+
lists. But in current (even as of the book's release) browsers they
74+
do.</p>
75+
7076
<p><strong>Page 234</strong> (2nd) <em>Creating Nodes</em>: In the
7177
code, “edition” is misspelled as “editon”.</p>
7278

0 commit comments

Comments
 (0)