diff --git a/lib/compress.js b/lib/compress.js index 6fbe2c8b..a28df7e7 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -827,6 +827,9 @@ merge(Compressor.prototype, { if (stat instanceof AST_SimpleStatement) { stat.body = (function transform(thing) { return thing.transform(new TreeTransformer(function(node){ + if (node instanceof AST_New) { + return node; + } if (node instanceof AST_Call && node.expression instanceof AST_Function) { return make_node(AST_UnaryPrefix, node, { operator: "!", diff --git a/test/compress/negate-iife.js b/test/compress/negate-iife.js index 89c3f064..b73ff547 100644 --- a/test/compress/negate-iife.js +++ b/test/compress/negate-iife.js @@ -74,3 +74,59 @@ negate_iife_4: { }(); } } + +negate_iife_nested: { + options = { + negate_iife: true, + sequences: true, + conditionals: true, + }; + input: { + function Foo(f) { + this.f = f; + } + new Foo(function() { + (function(x) { + (function(y) { + console.log(y); + })(x); + })(7); + }).f(); + } + expect: { + function Foo(f) { + this.f = f; + } + new Foo(function() { + !function(x) { + !function(y) { + console.log(y); + }(x); + }(7); + }).f(); + } +} + +negate_iife_issue_1073: { + options = { + negate_iife: true, + sequences: true, + conditionals: true, + }; + input: { + new (function(a) { + return function Foo() { + this.x = a; + console.log(this); + }; + }(7))(); + } + expect: { + new (function(a) { + return function Foo() { + this.x = a, + console.log(this); + }; + }(7))(); + } +}