Simplify iife new fix
as suggested by @rvanvelzen. Added a test for IIFEs in nested contexts.
This commit is contained in:
@@ -811,9 +811,7 @@ 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
|
if (node instanceof AST_New) {
|
||||||
&& node.expression instanceof AST_Call
|
|
||||||
&& node.expression.expression instanceof AST_Function) {
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_Call && node.expression instanceof AST_Function) {
|
if (node instanceof AST_Call && node.expression instanceof AST_Function) {
|
||||||
|
|||||||
@@ -75,6 +75,38 @@ negate_iife_4: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
negate_iife_nested: {
|
||||||
|
options = {
|
||||||
|
negate_iife: true,
|
||||||
|
sequences: true,
|
||||||
|
conditionals: true,
|
||||||
|
};
|
||||||
|
input: {
|
||||||
|
function Foo(f) {
|
||||||
|
this.f = f;
|
||||||
|
}
|
||||||
|
new Foo(function() {
|
||||||
|
(function(x) {
|
||||||
|
(function(y) {
|
||||||
|
console.log(y);
|
||||||
|
})(x);
|
||||||
|
})(7);
|
||||||
|
}).f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function Foo(f) {
|
||||||
|
this.f = f;
|
||||||
|
}
|
||||||
|
new Foo(function() {
|
||||||
|
!function(x) {
|
||||||
|
!function(y) {
|
||||||
|
console.log(y);
|
||||||
|
}(x);
|
||||||
|
}(7);
|
||||||
|
}).f();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
negate_iife_issue_1073: {
|
negate_iife_issue_1073: {
|
||||||
options = {
|
options = {
|
||||||
negate_iife: true,
|
negate_iife: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user