Skip to content

Commit

Permalink
fix: ensure […map.keys] can be correctly transformed in loose mode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jul 31, 2020
1 parent 0805418 commit c41dcd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/babel-plugin-transform-block-scoping/src/index.js
Expand Up @@ -518,7 +518,7 @@ class BlockScoping {
// remap loop heads with colliding variables
if (this.loop) {
// nb: clone outsideRefs keys since the map is modified within the loop
for (const name of [...outsideRefs.keys()]) {
for (const name of Array.from(outsideRefs.keys())) {
const id = outsideRefs.get(name);

if (
Expand Down
7 changes: 7 additions & 0 deletions packages/babel-standalone/test/babel.js
Expand Up @@ -210,6 +210,13 @@
}),
).not.toThrow();
});
it("#11897 - [...map.keys()] in Babel source should be transformed correctly", () => {
expect(() =>
Babel.transform("for (let el of []) { s => el }", {
plugins: ["transform-block-scoping"],
}),
).not.toThrow();
});
});
},
);

0 comments on commit c41dcd0

Please sign in to comment.