-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Transform scoping for
for X
in loop (#16384)
* fix * review
- Loading branch information
1 parent
b8eb831
commit a0b1653
Showing
5 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...ages/babel-plugin-transform-block-scoping/test/fixtures/general/for-inside-for-x/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function w() { | ||
for (let i = 0; i < y; i++) { | ||
let outer = {} | ||
for (var key in someObj) { | ||
let x = () => outer; | ||
} | ||
} | ||
} | ||
|
||
function w2() { | ||
for (let i = 0; i < y; i++) { | ||
let outer = {} | ||
for (var key of someObj) { | ||
let x = () => outer; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ges/babel-plugin-transform-block-scoping/test/fixtures/general/for-inside-for-x/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function w() { | ||
var _loop = function () { | ||
var outer = {}; | ||
for (key in someObj) { | ||
var x = function () { | ||
return outer; | ||
}; | ||
} | ||
}, | ||
key; | ||
for (var i = 0; i < y; i++) { | ||
_loop(); | ||
} | ||
} | ||
function w2() { | ||
var _loop2 = function () { | ||
var outer = {}; | ||
for (key of someObj) { | ||
var x = function () { | ||
return outer; | ||
}; | ||
} | ||
}, | ||
key; | ||
for (var i = 0; i < y; i++) { | ||
_loop2(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...ages/babel-plugin-transform-block-scoping/test/fixtures/general/for-x-inside-for/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function w() { | ||
for (let key in someObj) { | ||
let outer = {} | ||
for (var i = 0; i < y; i++) { | ||
let x = () => outer; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ges/babel-plugin-transform-block-scoping/test/fixtures/general/for-x-inside-for/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function w() { | ||
var _loop = function () { | ||
var outer = {}; | ||
for (i = 0; i < y; i++) { | ||
var x = function () { | ||
return outer; | ||
}; | ||
} | ||
}, | ||
i; | ||
for (var key in someObj) { | ||
_loop(); | ||
} | ||
} |