Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move array reference into
for
head initializer (#9698)
* Move array reference into for head initializer * Update packages/babel-plugin-transform-for-of/src/index.js Co-Authored-By: danez <daniel@tschinder.de> * Fix tests
- Loading branch information
Showing
9 changed files
with
26 additions
and
56 deletions.
There are no files selected for viewing
5 changes: 2 additions & 3 deletions
5
packages/babel-core/test/fixtures/transformation/misc/regression-1169/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
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
10 changes: 4 additions & 6 deletions
10
packages/babel-plugin-transform-for-of/test/fixtures/opt/array-binding/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 |
---|---|---|
@@ -1,13 +1,11 @@ | ||
const x = []; | ||
var _arr = x; | ||
|
||
for (var _i = 0; _i < _arr.length; _i++) { | ||
const y = _arr[_i]; | ||
for (var _i = 0, _x = x; _i < _x.length; _i++) { | ||
const y = _x[_i]; | ||
} | ||
|
||
const arr = Object.entries(x); | ||
var _arr2 = arr; | ||
|
||
for (var _i2 = 0; _i2 < _arr2.length; _i2++) { | ||
const y = _arr2[_i2]; | ||
for (var _i2 = 0, _arr = arr; _i2 < _arr.length; _i2++) { | ||
const y = _arr[_i2]; | ||
} |
28 changes: 9 additions & 19 deletions
28
packages/babel-plugin-transform-for-of/test/fixtures/opt/built-ins/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 |
---|---|---|
@@ -1,29 +1,19 @@ | ||
var _arr = []; | ||
|
||
for (var _i = 0; _i < _arr.length; _i++) { | ||
for (var _i = 0, _arr = []; _i < _arr.length; _i++) { | ||
const y = _arr[_i]; | ||
} | ||
|
||
var _arr2 = Array.from(x); | ||
|
||
for (var _i2 = 0; _i2 < _arr2.length; _i2++) { | ||
const y = _arr2[_i2]; | ||
for (var _i2 = 0, _Array$from = Array.from(x); _i2 < _Array$from.length; _i2++) { | ||
const y = _Array$from[_i2]; | ||
} | ||
|
||
var _arr3 = Object.keys(x); | ||
|
||
for (var _i3 = 0; _i3 < _arr3.length; _i3++) { | ||
const y = _arr3[_i3]; | ||
for (var _i3 = 0, _Object$keys = Object.keys(x); _i3 < _Object$keys.length; _i3++) { | ||
const y = _Object$keys[_i3]; | ||
} | ||
|
||
var _arr4 = Object.values(x); | ||
|
||
for (var _i4 = 0; _i4 < _arr4.length; _i4++) { | ||
const y = _arr4[_i4]; | ||
for (var _i4 = 0, _Object$values = Object.values(x); _i4 < _Object$values.length; _i4++) { | ||
const y = _Object$values[_i4]; | ||
} | ||
|
||
var _arr5 = Object.entries(x); | ||
|
||
for (var _i5 = 0; _i5 < _arr5.length; _i5++) { | ||
const y = _arr5[_i5]; | ||
for (var _i5 = 0, _Object$entries = Object.entries(x); _i5 < _Object$entries.length; _i5++) { | ||
const y = _Object$entries[_i5]; | ||
} |
4 changes: 1 addition & 3 deletions
4
packages/babel-plugin-transform-for-of/test/fixtures/opt/typeannotation/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
4 changes: 1 addition & 3 deletions
4
...ages/babel-plugin-transform-for-of/test/fixtures/regression/if-block-label-3858/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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
if (true) { | ||
var _arr = []; | ||
|
||
loop: for (var _i = 0; _i < _arr.length; _i++) { | ||
loop: for (var _i = 0, _arr = []; _i < _arr.length; _i++) { | ||
let ch = _arr[_i]; | ||
} | ||
} |
4 changes: 1 addition & 3 deletions
4
packages/babel-plugin-transform-for-of/test/fixtures/regression/if-label-3858/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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
if (true) { | ||
var _arr = []; | ||
|
||
loop: for (var _i = 0; _i < _arr.length; _i++) { | ||
loop: for (var _i = 0, _arr = []; _i < _arr.length; _i++) { | ||
let ch = _arr[_i]; | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
...ges/babel-plugin-transform-for-of/test/fixtures/regression/redeclare-array-8913/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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
function f(...t) { | ||
var _arr = t; | ||
|
||
for (var _i = 0; _i < _arr.length; _i++) { | ||
let o = _arr[_i]; | ||
for (var _i = 0, _t = t; _i < _t.length; _i++) { | ||
let o = _t[_i]; | ||
const t = o; | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
packages/babel-plugin-transform-for-of/test/fixtures/regression/scope-9696/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