[Pkg-javascript-commits] [uglifyjs] 288/491: make `AST_Lambda.contains_this()` less magical (#2505)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:45 UTC 2018


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

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit aa9bdf416e5b288bbae8417780abf2f235bacfd4
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Nov 24 07:03:37 2017 +0800

    make `AST_Lambda.contains_this()` less magical (#2505)
---
 lib/compress.js | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index 987ad01..ce881c0 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -610,7 +610,8 @@ merge(Compressor.prototype, {
                 || !immutable
                     && parent instanceof AST_Call
                     && parent.expression === node
-                    && (!(value instanceof AST_Function) || value.contains_this(parent))) {
+                    && (!(value instanceof AST_Function)
+                        || !(parent instanceof AST_New) && value.contains_this())) {
                 return true;
             } else if (parent instanceof AST_Array) {
                 return is_modified(parent, parent, level + 1);
@@ -4764,8 +4765,7 @@ merge(Compressor.prototype, {
         return self;
     });
 
-    AST_Lambda.DEFMETHOD("contains_this", function(grandparent) {
-        if (grandparent instanceof AST_New) return false;
+    AST_Lambda.DEFMETHOD("contains_this", function() {
         var result;
         var self = this;
         self.walk(new TreeWalker(function(node) {
@@ -4789,7 +4789,8 @@ merge(Compressor.prototype, {
                     })) break;
                     var value = prop.value;
                     if (value instanceof AST_Function
-                        && value.contains_this(compressor.parent())) break;
+                        && !(compressor.parent() instanceof AST_New)
+                        && value.contains_this()) break;
                     return make_node(AST_Sub, this, {
                         expression: make_node(AST_Array, expr, {
                             elements: props.map(function(prop) {

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