Skip to content

Commit 15bf32c

Browse files
marclavalbenlesh
authored andcommitted
fix(util): incorrect Symbol.iterator for es6-shim
1 parent 9f0ecf7 commit 15bf32c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/util/Symbol_iterator.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,18 @@ if (!root.Symbol.iterator) {
1010
} else if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
1111
// Bug for mozilla version
1212
root.Symbol.iterator = '@@iterator';
13+
} else if (root.Map) {
14+
// es6-shim specific logic
15+
let keys = Object.getOwnPropertyNames(root.Map.prototype);
16+
for (let i = 0; i < keys.length; ++i) {
17+
let key = keys[i];
18+
if (key !== 'entries' && key !== 'size' && root.Map.prototype[key] === root.Map.prototype['entries']) {
19+
root.Symbol.iterator = key;
20+
break;
21+
}
22+
}
1323
} else {
14-
root.Symbol.iterator = '_es6shim_iterator_';
24+
root.Symbol.iterator = '@@iterator';
1525
}
1626
}
1727

0 commit comments

Comments
 (0)