Do not apply negate_iife optimization to new expression
This commit is contained in:
parent
a0e03c9df4
commit
bcc1318d4b
|
|
@ -811,6 +811,11 @@ merge(Compressor.prototype, {
|
||||||
if (stat instanceof AST_SimpleStatement) {
|
if (stat instanceof AST_SimpleStatement) {
|
||||||
stat.body = (function transform(thing) {
|
stat.body = (function transform(thing) {
|
||||||
return thing.transform(new TreeTransformer(function(node){
|
return thing.transform(new TreeTransformer(function(node){
|
||||||
|
if (node instanceof AST_New
|
||||||
|
&& node.expression instanceof AST_Call
|
||||||
|
&& node.expression.expression instanceof AST_Function) {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
if (node instanceof AST_Call && node.expression instanceof AST_Function) {
|
if (node instanceof AST_Call && node.expression instanceof AST_Function) {
|
||||||
return make_node(AST_UnaryPrefix, node, {
|
return make_node(AST_UnaryPrefix, node, {
|
||||||
operator: "!",
|
operator: "!",
|
||||||
|
|
|
||||||
|
|
@ -74,3 +74,27 @@ negate_iife_4: {
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
negate_iife_issue_1073: {
|
||||||
|
options = {
|
||||||
|
negate_iife: true,
|
||||||
|
sequences: true,
|
||||||
|
conditionals: true,
|
||||||
|
};
|
||||||
|
input: {
|
||||||
|
new (function(a) {
|
||||||
|
return function Foo() {
|
||||||
|
this.x = a;
|
||||||
|
console.log(this);
|
||||||
|
};
|
||||||
|
}(7))();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
new (function(a) {
|
||||||
|
return function Foo() {
|
||||||
|
this.x = a,
|
||||||
|
console.log(this);
|
||||||
|
};
|
||||||
|
}(7))();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user