ensure order of execution

This commit is contained in:
alexlamsl 2017-12-18 14:07:21 +08:00
parent 3bd99ccdd8
commit b12379d465
2 changed files with 9 additions and 5 deletions

View File

@ -3847,18 +3847,16 @@ merge(Compressor.prototype, {
}
break;
case "apply":
if (self.args[1] instanceof AST_Array) {
var expressions = self.args.slice(2);
if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
var args = self.args[1].elements.slice();
args.unshift(self.args[0]);
expressions.unshift(make_node(AST_Call, self, {
return make_node(AST_Call, self, {
expression: make_node(AST_Dot, exp, {
expression: exp.expression,
property: "call"
}),
args: args
}));
return make_sequence(self, expressions).optimize(compressor);
}).optimize(compressor);
}
break;
case "call":

View File

@ -940,12 +940,18 @@ unsafe_apply_1: {
(function(a, b) {
console.log(this, a, b);
}).apply("foo", [ "bar" ]);
(function(a, b) {
console.log(a, b);
}).apply("foo", [ "bar" ], "baz");
}
expect: {
console.log("bar", void 0);
(function(a, b) {
console.log(this, a, b);
}).call("foo", "bar");
(function(a, b) {
console.log(a, b);
}).apply("foo", [ "bar" ], "baz");
}
expect_stdout: true
}