File tree 6 files changed +80
-1
lines changed
terser/compress/hoist_props/contains_this_1
6 files changed +80
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ swc_ecma_minifier : patch
3
+ ---
4
+
5
+ fix(es/minifier): Fix detection of ` this `
Original file line number Diff line number Diff line change @@ -846,6 +846,38 @@ impl Optimizer<'_> {
846
846
PropOrSpread :: Prop ( prop) => prop,
847
847
} ;
848
848
849
+ match & * * prop {
850
+ Prop :: Method ( prop) => {
851
+ if contains_this_expr ( & prop. function . body ) {
852
+ return None ;
853
+ }
854
+ }
855
+ Prop :: Getter ( prop) => {
856
+ if contains_this_expr ( & prop. body ) {
857
+ return None ;
858
+ }
859
+ }
860
+ Prop :: Setter ( prop) => {
861
+ if contains_this_expr ( & prop. body ) {
862
+ return None ;
863
+ }
864
+ }
865
+ Prop :: KeyValue ( prop) => match & * prop. value {
866
+ Expr :: Fn ( f) => {
867
+ if contains_this_expr ( & f. function . body ) {
868
+ return None ;
869
+ }
870
+ }
871
+ Expr :: Arrow ( f) => {
872
+ if contains_this_expr ( & f. body ) {
873
+ return None ;
874
+ }
875
+ }
876
+ _ => { }
877
+ } ,
878
+ _ => { }
879
+ }
880
+
849
881
if contains_this_expr ( prop) {
850
882
return None ;
851
883
}
Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ const Cache = {
8
8
get : function ( key ) {
9
9
if ( ! 1 !== this . enabled ) // console.log( 'THREE.Cache', 'Checking key:', key );
10
10
return this . files [ key ] ;
11
+ } ,
12
+ remove : function ( key ) {
13
+ delete this . files [ key ] ;
14
+ } ,
15
+ clear : function ( ) {
16
+ this . files = { } ;
11
17
}
12
18
} ;
13
19
class Loader {
Original file line number Diff line number Diff line change
1
+ function foo ( ) {
2
+ const obj = {
3
+ clear : function ( ) {
4
+ console . log ( 'clear' )
5
+ } ,
6
+ start : function ( ) {
7
+ const _this = this ;
8
+ setTimeout ( function ( ) {
9
+ _this . clear ( ) ;
10
+ } ) ;
11
+ }
12
+ } ;
13
+ return ( ) => obj . start ( )
14
+ } ;
15
+
16
+ export default foo ( )
Original file line number Diff line number Diff line change
1
+ export default ( function ( ) {
2
+ const obj = {
3
+ clear : function ( ) {
4
+ console . log ( 'clear' ) ;
5
+ } ,
6
+ start : function ( ) {
7
+ const _this = this ;
8
+ setTimeout ( function ( ) {
9
+ _this . clear ( ) ;
10
+ } ) ;
11
+ }
12
+ } ;
13
+ return ( ) => obj . start ( ) ;
14
+ } ) ( ) ;
Original file line number Diff line number Diff line change 1
- console . log ( 1 , 1 ) ;
1
+ var o = {
2
+ u : function ( ) {
3
+ return this === this ;
4
+ } ,
5
+ p : 1
6
+ } ;
7
+ console . log ( o . p , o . p ) ;
You can’t perform that action at this time.
0 commit comments