var token = node.end;
if (!token) return;
var comments = token[tail ? "comments_before" : "comments_after"];
- if (comments && comments._dumped !== self) {
+ if (comments
+ && comments._dumped !== self
+ && (node instanceof AST_Statement || all(comments, function(c) {
+ return !/comment[134]/.test(c.type);
+ }))) {
comments._dumped = self;
var insert = OUTPUT.length;
comments.filter(comment_filter, node).forEach(function(c, i) {
add_mapping : add_mapping,
option : function(opt) { return options[opt] },
prepend_comments: readonly ? noop : prepend_comments,
- append_comments : readonly ? noop : append_comments,
+ append_comments : readonly || comment_filter === return_false ? noop : append_comments,
line : function() { return current_line },
col : function() { return current_col },
pos : function() { return current_pos },
if (result.error) throw result.error;
assert.strictEqual(result.code, "/*a*/ /*b*/(function(){/*c*/}/*d*/ /*e*/)();");
});
+
+ it("Should output line comments after statements", function() {
+ var result = uglify.minify([
+ "x()//foo",
+ "{y()//bar",
+ "}",
+ ].join("\n"), {
+ compress: false,
+ mangle: false,
+ output: {
+ comments: "all",
+ },
+ });
+ if (result.error) throw result.error;
+ assert.strictEqual(result.code, [
+ "x();//foo",
+ "{y();//bar",
+ "}",
+ ].join("\n"));
+ });
});