[Pkg-javascript-commits] [uglifyjs] 149/190: Do not apply negate_iife optimization to `new` expression

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Aug 7 23:17:21 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.

commit bcc1318d4b7275feee02f782700d6b6e4a68b54f
Author: kzc <zaxxon2011 at gmail.com>
Date:   Mon May 9 03:19:28 2016 -0400

    Do not apply negate_iife optimization to `new` expression
---
 lib/compress.js              |  5 +++++
 test/compress/negate-iife.js | 24 ++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/lib/compress.js b/lib/compress.js
index 2bcfcf3..1d6a943 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -811,6 +811,11 @@ 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
+                                && node.expression instanceof AST_Call
+                                && node.expression.expression instanceof AST_Function) {
+                                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 89c3f06..20b3f56 100644
--- a/test/compress/negate-iife.js
+++ b/test/compress/negate-iife.js
@@ -74,3 +74,27 @@ negate_iife_4: {
         }();
     }
 }
+
+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))();
+    }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list