File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -838,6 +838,14 @@ merge(Compressor.prototype, {
838
838
return false ;
839
839
}
840
840
841
+ function is_completion_statement ( node ) {
842
+ if ( compressor . parent ( ) ) {
843
+ return false ;
844
+ }
845
+
846
+ return statements [ statements . length - 1 ] . body === node ;
847
+ }
848
+
841
849
statements . forEach ( function ( stat ) {
842
850
if ( stat instanceof AST_SimpleStatement ) {
843
851
stat . body = ( function transform ( thing ) {
@@ -846,6 +854,8 @@ merge(Compressor.prototype, {
846
854
return node ;
847
855
}
848
856
if ( is_iife_call ( node ) ) {
857
+ if ( is_completion_statement ( node ) ) return node ;
858
+
849
859
return make_node ( AST_UnaryPrefix , node , {
850
860
operator : "!" ,
851
861
expression : node
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ negate_iife_1: {
6
6
( function ( ) { stuff ( ) } ) ( ) ;
7
7
}
8
8
expect: {
9
- ! function ( ) { stuff ( ) } ( ) ;
9
+ ( function ( ) { stuff ( ) } ) ( ) ;
10
10
}
11
11
}
12
12
@@ -156,7 +156,7 @@ issue_1254_negate_iife_true: {
156
156
} ;
157
157
} ) ( ) ( ) ;
158
158
}
159
- expect_exact: '! function(){return function(){console.log("test")}}()();'
159
+ expect_exact: '( function(){return function(){console.log("test")}}) ()();'
160
160
}
161
161
162
162
issue_1254_negate_iife_nested: {
@@ -170,5 +170,17 @@ issue_1254_negate_iife_nested: {
170
170
} ;
171
171
} ) ( ) ( ) ( ) ( ) ( ) ;
172
172
}
173
- expect_exact: '!function(){return function(){console.log("test")}}()()()()();'
173
+ expect_exact: '(function(){return function(){console.log("test")}})()()()()();'
174
+ }
175
+
176
+ preserve_completion_value: {
177
+ options = {
178
+ negate_iife : true ,
179
+ }
180
+ input: {
181
+ ( function ( ) { return true ; } ) ( ) ;
182
+ ( function ( ) { return true ; } ) ( ) ;
183
+ ( function ( ) { return true ; } ) ( ) ;
184
+ }
185
+ expect_exact: '!function(){return true}();!function(){return true}();(function(){return true})();'
174
186
}
You can’t perform that action at this time.
0 commit comments