Allow for-of on polyfilled or builtin iterables without Symbol support (#11285)

This commit is contained in:
Nicolò Ribaudo
2020-03-19 11:02:12 +01:00
committed by GitHub
parent 6f932978f8
commit fa7ec81771
4 changed files with 47 additions and 7 deletions

View File

@@ -0,0 +1,18 @@
function getArgs() { return arguments; }
let args = getArgs(1, 2, 3);
let res = [];
// Simulate old environment
delete args[Symbol.iterator];
let _Symbol = Symbol;
Symbol = void 0;
try {
for (let i of args) res.push(i);
expect(res).toEqual([1, 2, 3]);
} finally {
Symbol = _Symbol;
}

View File

@@ -0,0 +1,18 @@
function getArgs() { return arguments; }
let args = getArgs(1, 2, 3);
let res = [];
// Simulate old environment
delete args[Symbol.iterator];
let _Symbol = Symbol;
Symbol = void 0;
try {
for (let i of args) res.push(i);
expect(res).toEqual([1, 2, 3]);
} finally {
Symbol = _Symbol;
}