aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRichard van Velzen <rvanvelzen@experty.com>2016-08-17 11:43:50 +0200
committerRichard van Velzen <rvanvelzen@experty.com>2016-08-17 11:55:59 +0200
commit8430123e9d2d12442312bbdcdf54004dc6d29c12 (patch)
tree866efd1f204309549e5961eb09a87defd8eeafa5 /lib
parent614db97cca9d4ccf84af2597aa8b97285646e729 (diff)
downloadtracifyjs-8430123e9d2d12442312bbdcdf54004dc6d29c12.tar.gz
tracifyjs-8430123e9d2d12442312bbdcdf54004dc6d29c12.zip
Fix negate_iife transform to return a correct tree for nested IIFEs
Fix for #1256, partially reverts d854523783b4
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js9
-rw-r--r--lib/output.js2
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js
index fd839fa1..f8d9d329 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -831,6 +831,13 @@ merge(Compressor.prototype, {
};
function negate_iifes(statements, compressor) {
+ function is_iife_call(node) {
+ if (node instanceof AST_Call) {
+ return node.expression instanceof AST_Function || is_iife_call(node.expression);
+ }
+ return false;
+ }
+
statements.forEach(function(stat){
if (stat instanceof AST_SimpleStatement) {
stat.body = (function transform(thing) {
@@ -838,7 +845,7 @@ merge(Compressor.prototype, {
if (node instanceof AST_New) {
return node;
}
- if (node instanceof AST_Call && node.expression instanceof AST_Function) {
+ if (is_iife_call(node)) {
return make_node(AST_UnaryPrefix, node, {
operator: "!",
expression: node
diff --git a/lib/output.js b/lib/output.js
index f1e0c2f1..801f7516 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -531,8 +531,6 @@ function OutputStream(options) {
});
PARENS([ AST_Unary, AST_Undefined ], function(output){
- if (this.expression instanceof AST_Call)
- return false;
var p = output.parent();
return p instanceof AST_PropAccess && p.expression === this
|| p instanceof AST_Call && p.expression === this;