8000 fix: ensure `[…map.keys]` can be correctly transformed in loose mode … · babel/babel@c41dcd0 · GitHub
[go: up one dir, main page]

Skip to content

Commit c41dcd0

Browse files
authored
fix: ensure […map.keys] can be correctly transformed in loose mode (#11901)
1 parent 0805418 commit c41dcd0

File tree

2 files changed

+8
-1
lines changed
  • packages

2 files changed

+8
-1
lines changed

packages/babel-plugin-transform-block-scoping/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class BlockScoping {
518518
// remap loop heads with colliding variables
519519
if (this.loop) {
520520
// nb: clone outsideRefs keys since the map is modified within the loop
521-
for (const name of [...outsideRefs.keys()]) {
521+
for (const name of Array.from(outsideRefs.keys())) {
522522
const id = outsideRefs.get(name);
523523

524524
if (

packages/babel-standalone/test/babel.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@
210210
}),
211211
).not.toThrow();
212212
});
213+
it("#11897 - [...map.keys()] in Babel source should be transformed correctly", () => {
214+
expect(() =>
215+
Babel.transform("for (let el of []) { s => el }", {
216+
plugins: ["transform-block-scoping"],
217+
}),
218+
).not.toThrow();
219+
});
213220
});
214221
},
215222
);

0 commit comments

Comments
 (0)
0