From 8dda8838bad564c3e50216d9cc446d67537acda6 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 3 Mar 2015 09:37:52 +1100 Subject: [PATCH] check for body existence before length in dead code elimination transformer - fixes #931 --- .../transformers/utility/dead-code-elimination.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/babel/transformation/transformers/utility/dead-code-elimination.js b/src/babel/transformation/transformers/utility/dead-code-elimination.js index 438a5fac7f..c25c1e4266 100644 --- a/src/babel/transformation/transformers/utility/dead-code-elimination.js +++ b/src/babel/transformation/transformers/utility/dead-code-elimination.js @@ -77,7 +77,7 @@ export var IfStatement = { // if (foo) {} else { bar; } -> if (!foo) { bar; } // - if (t.blockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) { + if (t.blockStatement(consequent) && consequent.body && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body && alternate.body.length) { node.consequent = node.alternate; node.alternate = null; node.test = t.unaryExpression("!", test, true);