[Pkg-javascript-commits] [uglifyjs] 150/190: Simplify iife `new` fix

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 5f464b41e2ba95f4d81da262a260488d326eb633
Author: kzc <zaxxon2011 at gmail.com>
Date:   Sun May 15 19:12:17 2016 -0400

    Simplify iife `new` fix
    
    as suggested by @rvanvelzen.
    
    Added a test for IIFEs in nested contexts.
---
 lib/compress.js              |  4 +---
 test/compress/negate-iife.js | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index 1d6a943..6436796 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -811,9 +811,7 @@ 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) {
+                            if (node instanceof AST_New) {
                                 return node;
                             }
                             if (node instanceof AST_Call && node.expression instanceof AST_Function) {
diff --git a/test/compress/negate-iife.js b/test/compress/negate-iife.js
index 20b3f56..b73ff54 100644
--- a/test/compress/negate-iife.js
+++ b/test/compress/negate-iife.js
@@ -75,6 +75,38 @@ 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,

-- 
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