From be55a09edf7526cd325e3c954e0ae778a1f625b0 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Wed, 18 Dec 2013 13:30:26 +0200 Subject: Take out all comments from an AST_Exit's value Fix #372 --- lib/output.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/output.js b/lib/output.js index 37e30c0e..1ef92dde 100644 --- a/lib/output.js +++ b/lib/output.js @@ -386,13 +386,14 @@ function OutputStream(options) { var comments = start.comments_before || []; // XXX: ugly fix for https://github.com/mishoo/UglifyJS2/issues/112 - // if this node is `return` or `throw`, we cannot allow comments before - // the returned or thrown value. - if (self instanceof AST_Exit && self.value - && self.value.start.comments_before - && self.value.start.comments_before.length > 0) { - comments = comments.concat(self.value.start.comments_before); - self.value.start.comments_before = []; + // and https://github.com/mishoo/UglifyJS2/issues/372 + if (self instanceof AST_Exit && self.value) { + self.value.walk(new TreeWalker(function(node){ + if (node.start.comments_before) { + comments = comments.concat(node.start.comments_before); + node.start.comments_before = []; + } + })); } if (c.test) { -- cgit v1.2.3