Skip to content

Commit cf44066

Browse files
committed
stream: treat null asyncIterator as undefined
According to the spec, getIterator should normalize incoming method to undefined if it is either undefined or null. This PR enforces that spec compliance with passed WPT.
1 parent 5c22d19 commit cf44066

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

lib/internal/webstreams/util.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,12 @@ function createAsyncFromSyncIterator(syncIteratorRecord) {
211211
return { iterator: asyncIterator, nextMethod, done: false };
212212
}
213213

214+
// Refs: https://tc39.es/ecma262/#sec-getiterator
214215
function getIterator(obj, kind = 'sync', method) {
215216
if (method === undefined) {
216217
if (kind === 'async') {
217218
method = obj[SymbolAsyncIterator];
218-
if (method === undefined) {
219+
if (method === undefined || method === null) {
219220
const syncMethod = obj[SymbolIterator];
220221

221222
if (syncMethod === undefined) {

test/wpt/status/streams.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
"readable-streams/cross-realm-crash.window.js": {
1717
"skip": "Browser-specific test"
1818
},
19-
"readable-streams/from.any.js": {
20-
"fail": {
21-
"expected": [
22-
"ReadableStream.from ignores a null @@asyncIterator"
23-
]
24-
}
25-
},
2619
"readable-streams/owning-type-message-port.any.js": {
2720
"fail": {
2821
"note": "Readable streams with type owning are not yet supported",

0 commit comments

Comments
 (0)