Only compress code in new Function if all arguments are strings.
This commit is contained in:
@@ -1590,7 +1590,7 @@ merge(Compressor.prototype, {
|
|||||||
right: make_node(AST_String, self, { value: "" })
|
right: make_node(AST_String, self, { value: "" })
|
||||||
});
|
});
|
||||||
case "Function":
|
case "Function":
|
||||||
if (self.args[self.args.length - 1] instanceof AST_String) {
|
if (all(self.args, function(x){ return x instanceof AST_String })) {
|
||||||
// quite a corner-case, but we can handle it:
|
// quite a corner-case, but we can handle it:
|
||||||
// https://github.com/mishoo/UglifyJS2/issues/203
|
// https://github.com/mishoo/UglifyJS2/issues/203
|
||||||
// if the code argument is a constant, then we can minify it.
|
// if the code argument is a constant, then we can minify it.
|
||||||
|
|||||||
@@ -245,6 +245,13 @@ function makePredicate(words) {
|
|||||||
return new Function("str", f);
|
return new Function("str", f);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function all(array, predicate) {
|
||||||
|
for (var i = array.length; --i >= 0;)
|
||||||
|
if (!predicate(array[i]))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
function Dictionary() {
|
function Dictionary() {
|
||||||
this._values = Object.create(null);
|
this._values = Object.create(null);
|
||||||
this._size = 0;
|
this._size = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user