-
Notifications
You must be signed in to change notification settings - Fork 5.8k
fix(types): add [Symbol.iterator]() to NodeListOf (fixes #31382) #31384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(types): add [Symbol.iterator]() to NodeListOf (fixes #31382) #31384
Conversation
WalkthroughAdds Sequence Diagram(s)sequenceDiagram
autonumber
participant Test as Test (tsc test)
participant DOM as DOM (runtime)
participant Types as lib.dom.d.ts
Note over Types: Declaration change — NodeListOf has [Symbol.iterator]()
Test->>DOM: document.createElement("div")
Test->>DOM: div.innerHTML = "<p>a</p><p>b</p>"
Test->>DOM: for (const node of div.childNodes) { ... }
activate DOM
DOM->>DOM: div.childNodes (NodeListOf)
Note over DOM,Types `#dff0d8`: iteration uses\n[Symbol.iterator]() declared on NodeListOf
DOM-->>Test: yields Node (p, p) via iterator
deactivate DOM
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
a7bbe2b to
d05388f
Compare
|
Kindly requesting a review when convenient. |
fix(types): add
[Symbol.iterator]()toNodeListOfThis PR adds missing iterable support to
NodeListOf<TNode>in the DOMtypings. Without this method, TypeScript raises error TS2488:
This brings Deno’s DOM types in line with upstream
lib.dom.d.ts, whereNodeListOfis defined as iterable.Related Issue
Fixes #31382
Details
The following method was added to
NodeListOf<TNode>:This is a type-only change and does not affect the runtime behavior of Deno.
The fix allows idiomatic iteration over
NodeListOf, such as: