-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/minifier): Check
this
in function params (#9229)
**Related issue:** - Closes #9186
- Loading branch information
Showing
6 changed files
with
59 additions
and
1 deletion.
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
15 changes: 15 additions & 0 deletions
15
crates/swc_ecma_minifier/tests/fixture/issues/9186/1/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,15 @@ | ||
o = { | ||
foo() { | ||
return val; | ||
}, | ||
s: "test", | ||
}; | ||
console.log(o.foo().length); | ||
|
||
o = { | ||
foo(val = this.s) { | ||
return val; | ||
}, | ||
s: "test", | ||
}; | ||
console.log(o.foo().length); |
9 changes: 9 additions & 0 deletions
9
crates/swc_ecma_minifier/tests/fixture/issues/9186/1/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,9 @@ | ||
console.log((o = { | ||
foo: ()=>val, | ||
s: "test" | ||
}).foo().length), console.log((o = { | ||
foo (val1 = this.s) { | ||
return val1; | ||
}, | ||
s: "test" | ||
}).foo().length); |
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_minifier/tests/fixture/issues/9186/2/config.json
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,6 @@ | ||
{ | ||
"unsafe_arrows": true, | ||
"ecma": 2015, | ||
"evaluate": true, | ||
"side_effects": true | ||
} |
14 changes: 14 additions & 0 deletions
14
crates/swc_ecma_minifier/tests/fixture/issues/9186/2/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,14 @@ | ||
console.log( | ||
(function () { | ||
while (true) { | ||
console.log(123); | ||
} | ||
})() | ||
); | ||
console.log( | ||
(function (a = this.a) { | ||
while (true) { | ||
console.log(123); | ||
} | ||
})() | ||
); |
10 changes: 10 additions & 0 deletions
10
crates/swc_ecma_minifier/tests/fixture/issues/9186/2/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,10 @@ | ||
console.log((()=>{ | ||
while(true){ | ||
console.log(123); | ||
} | ||
})()); | ||
console.log(function(a = this.a) { | ||
while(true){ | ||
console.log(123); | ||
} | ||
}()); |