Merge 29e1ff0981 into eb55d8a9bb
This commit is contained in:
commit
c39e64a577
|
|
@ -845,6 +845,14 @@ merge(Compressor.prototype, {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_completion_statement(node) {
|
||||||
|
if (compressor.parent()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return statements[statements.length - 1].body === node;
|
||||||
|
}
|
||||||
|
|
||||||
statements.forEach(function(stat){
|
statements.forEach(function(stat){
|
||||||
if (stat instanceof AST_SimpleStatement) {
|
if (stat instanceof AST_SimpleStatement) {
|
||||||
stat.body = (function transform(thing) {
|
stat.body = (function transform(thing) {
|
||||||
|
|
@ -853,6 +861,8 @@ merge(Compressor.prototype, {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
if (is_iife_call(node)) {
|
if (is_iife_call(node)) {
|
||||||
|
if (is_completion_statement(node)) return node;
|
||||||
|
|
||||||
return make_node(AST_UnaryPrefix, node, {
|
return make_node(AST_UnaryPrefix, node, {
|
||||||
operator: "!",
|
operator: "!",
|
||||||
expression: node
|
expression: node
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ negate_iife_1: {
|
||||||
(function(){ stuff() })();
|
(function(){ stuff() })();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function(){ stuff() }();
|
(function(){ stuff() })();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,7 +156,7 @@ issue_1254_negate_iife_true: {
|
||||||
};
|
};
|
||||||
})()();
|
})()();
|
||||||
}
|
}
|
||||||
expect_exact: '!function(){return function(){console.log("test")}}()();'
|
expect_exact: '(function(){return function(){console.log("test")}})()();'
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1254_negate_iife_nested: {
|
issue_1254_negate_iife_nested: {
|
||||||
|
|
@ -170,5 +170,17 @@ issue_1254_negate_iife_nested: {
|
||||||
};
|
};
|
||||||
})()()()()();
|
})()()()()();
|
||||||
}
|
}
|
||||||
expect_exact: '!function(){return function(){console.log("test")}}()()()()();'
|
expect_exact: '(function(){return function(){console.log("test")}})()()()()();'
|
||||||
|
}
|
||||||
|
|
||||||
|
preserve_completion_value: {
|
||||||
|
options = {
|
||||||
|
negate_iife: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function () { return true; })();
|
||||||
|
(function () { return true; })();
|
||||||
|
(function () { return true; })();
|
||||||
|
}
|
||||||
|
expect_exact: '!function(){return true}();!function(){return true}();(function(){return true})();'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user