[Pkg-javascript-commits] [uglifyjs] 131/491: marshal `mangle[.properties].reserved` from non-Array values (#2072)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:28 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 293c566d6c8c6082c550ce5ca358da4cde124fac
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Jun 9 04:29:12 2017 +0800

    marshal `mangle[.properties].reserved` from non-Array values (#2072)
---
 lib/propmangle.js |  3 ++-
 lib/scope.js      |  4 +++-
 test/mocha/cli.js | 20 ++++++++++++++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/lib/propmangle.js b/lib/propmangle.js
index efb31cc..f17909d 100644
--- a/lib/propmangle.js
+++ b/lib/propmangle.js
@@ -78,7 +78,8 @@ function mangle_properties(ast, options) {
         reserved: null,
     });
 
-    var reserved = options.reserved || [];
+    var reserved = options.reserved;
+    if (!Array.isArray(reserved)) reserved = [];
     if (!options.builtins) find_builtins(reserved);
 
     var cache = options.cache;
diff --git a/lib/scope.js b/lib/scope.js
index 8bc9607..ea43f75 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -377,13 +377,15 @@ AST_Symbol.DEFMETHOD("global", function(){
 });
 
 AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options){
-    return defaults(options, {
+    options = defaults(options, {
         eval        : false,
         ie8         : false,
         keep_fnames : false,
         reserved    : [],
         toplevel    : false,
     });
+    if (!Array.isArray(options.reserved)) options.reserved = [];
+    return options;
 });
 
 AST_Toplevel.DEFMETHOD("mangle_names", function(options){
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index 0a7f8f2..3228e4e 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -546,4 +546,24 @@ describe("bin/uglifyjs", function () {
             done();
         });
     });
+    it("Should work with --mangle reserved=[]", function (done) {
+        var command = uglifyjscmd + ' test/input/issue-505/input.js -m reserved=[callback]';
+
+        exec(command, function (err, stdout) {
+            if (err) throw err;
+
+            assert.strictEqual(stdout, 'function test(callback){"aaaaaaaaaaaaaaaa";callback(err,data);callback(err,data)}\n');
+            done();
+        });
+    });
+    it("Should work with --mangle reserved=false", function (done) {
+        var command = uglifyjscmd + ' test/input/issue-505/input.js -m reserved=false';
+
+        exec(command, function (err, stdout) {
+            if (err) throw err;
+
+            assert.strictEqual(stdout, 'function test(a){"aaaaaaaaaaaaaaaa";a(err,data);a(err,data)}\n');
+            done();
+        });
+    });
 });

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