File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -1605,6 +1605,17 @@ impl<'a> PeepholeOptimizations {
1605
1605
ctx,
1606
1606
)
1607
1607
{
1608
+ if prop. shorthand && prop. key . is_specific_id ( "__proto__" ) {
1609
+ // { __proto__ } -> { ['__proto__']: value }
1610
+ prop. computed = true ;
1611
+ prop. key =
1612
+ PropertyKey :: from ( ctx. ast . expression_string_literal (
1613
+ prop. key . span ( ) ,
1614
+ "__proto__" ,
1615
+ None ,
1616
+ ) ) ;
1617
+ }
1618
+ prop. shorthand = false ;
1608
1619
return Some ( changed) ;
1609
1620
}
1610
1621
}
Original file line number Diff line number Diff line change @@ -212,6 +212,15 @@ fn test_inline_single_use_variable() {
212
212
"function wrapper() { var x = a; for (let a of x) console.log(a) }" ,
213
213
"function wrapper() { var x = a; for (let a of x) console.log(a) }" ,
214
214
) ;
215
+
216
+ test (
217
+ "function wrapper() { var __proto__ = []; return { __proto__: __proto__ } }" ,
218
+ "function wrapper() { return { __proto__: [] } }" ,
219
+ ) ;
220
+ test (
221
+ "function wrapper() { var __proto__ = []; return { __proto__ } }" ,
222
+ "function wrapper() { return { ['__proto__']: [] } }" ,
223
+ ) ;
215
224
}
216
225
217
226
#[ test]
Original file line number Diff line number Diff line change @@ -2,11 +2,9 @@ commit: ed0d6ba5
2
2
3
3
minifier_node_compat Summary :
4
4
AST Parsed : 938 / 938 (100.00 % )
5
- Positive Passed : 928 / 938 (98.93 % )
5
+ Positive Passed : 929 / 938 (99.04 % )
6
6
execution_result : tasks / coverage / ES2015 / annex b ›__proto__ in object literals ›basic support
7
7
8
- execution_result : tasks / coverage / ES2015 / annex b ›__proto__ in object literals ›not a shorthand property
9
-
10
8
execution_result : tasks / coverage / ES2015 / built - ins ›Proxy ›" getOwnPropertyDescriptor" handler invariants
11
9
12
10
execution_result : tasks / coverage / ES2015 / misc ›Proxy , internal ' get' calls ›HasBinding
You can’t perform that action at this time.
0 commit comments