diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-02-05 19:10:33 +0200 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-02-05 19:11:39 +0200 |
commit | 719a8fd10256da8c7a5d28d0125fefdfff1ba187 (patch) | |
tree | d7744d9daacd9ade3b77a332fb96a85d96548ea9 | |
parent | 3a22e917de1b4425255f2db514f30f42c5c6cec6 (diff) | |
download | tracifyjs-719a8fd10256da8c7a5d28d0125fefdfff1ba187.tar.gz tracifyjs-719a8fd10256da8c7a5d28d0125fefdfff1ba187.zip |
Ugly hack to print comments before return/throw statements
Close #112
-rw-r--r-- | lib/output.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/output.js b/lib/output.js index cafb28fb..5e668201 100644 --- a/lib/output.js +++ b/lib/output.js @@ -375,6 +375,16 @@ function OutputStream(options) { if (start && !start._comments_dumped) { start._comments_dumped = true; 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.length > 0) { + comments = (comments || []).concat(self.value.start.comments_before); + self.value.start.comments_before = []; + } + if (c.test) { comments = comments.filter(function(comment){ return c.test(comment.value); |