Skip to content

Commit

Permalink
marshal mangle[.properties].reserved from non-Array values (#2072)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Jun 8, 2017
1 parent 9c30640 commit 293c566
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/propmangle.js
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion lib/scope.js
Expand Up @@ -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){
Expand Down
20 changes: 20 additions & 0 deletions test/mocha/cli.js
Expand Up @@ -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();
});
});
});

0 comments on commit 293c566

Please sign in to comment.