fix: preserve shadowed for-loop declarators (#11242)
* fix: do not remove for-loop declarators * fix: do not remove uninitialized var declarators in for init
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
function foo(a = 2) {
|
||||
for (let a = 1; a > 0; a--);
|
||||
expect(a).toBe(2);
|
||||
}
|
||||
foo();
|
||||
@@ -0,0 +1,5 @@
|
||||
function foo(a = 2) {
|
||||
for (let a, i = 0; i < 1; i++) a = 1;
|
||||
expect(a).toBe(2);
|
||||
}
|
||||
foo();
|
||||
@@ -0,0 +1,5 @@
|
||||
function foo(a = 2) {
|
||||
for (var i of [0]) var a = 1;
|
||||
expect(a).toBe(1);
|
||||
}
|
||||
foo();
|
||||
@@ -0,0 +1,5 @@
|
||||
function foo(a = 2) {
|
||||
for (var [a] of [[1]]);
|
||||
expect(a).toBe(1);
|
||||
}
|
||||
foo();
|
||||
@@ -0,0 +1,5 @@
|
||||
function foo(a = 2) {
|
||||
for (var i of [0]) var a;
|
||||
expect(a).toBe(2);
|
||||
}
|
||||
foo();
|
||||
@@ -0,0 +1,5 @@
|
||||
function foo(a = 2) {
|
||||
for (var a, i = 0; i < 1; i++);
|
||||
expect(a).toBe(undefined);
|
||||
}
|
||||
foo();
|
||||
3
packages/babel-plugin-transform-parameters/test/fixtures/regression/11231/input.mjs
vendored
Normal file
3
packages/babel-plugin-transform-parameters/test/fixtures/regression/11231/input.mjs
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
(i = "__proto__") => {
|
||||
for (var i in {});
|
||||
};
|
||||
5
packages/babel-plugin-transform-parameters/test/fixtures/regression/11231/options.json
vendored
Normal file
5
packages/babel-plugin-transform-parameters/test/fixtures/regression/11231/options.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-parameters"
|
||||
]
|
||||
}
|
||||
6
packages/babel-plugin-transform-parameters/test/fixtures/regression/11231/output.mjs
vendored
Normal file
6
packages/babel-plugin-transform-parameters/test/fixtures/regression/11231/output.mjs
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
(function () {
|
||||
let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "__proto__";
|
||||
return function () {
|
||||
for (var i in {});
|
||||
}();
|
||||
});
|
||||
Reference in New Issue
Block a user