Avoid printing <!-- in the output (HTML5 comment)
authorMihai Bazon <mihai@bazon.net>
Fri, 6 Sep 2013 07:10:45 +0000 (10:10 +0300)
committerMihai Bazon <mihai@bazon.net>
Fri, 6 Sep 2013 07:10:45 +0000 (10:10 +0300)
lib/output.js

index df2692a..e7f3f4d 100644 (file)
@@ -989,7 +989,18 @@ function OutputStream(options) {
         self.left.print(output);
         output.space();
         output.print(self.operator);
-        output.space();
+        if (self.operator == "<"
+            && self.right instanceof AST_UnaryPrefix
+            && self.right.operator == "!"
+            && self.right.expression instanceof AST_UnaryPrefix
+            && self.right.expression.operator == "--") {
+            // space is mandatory to avoid outputting <!--
+            // http://javascript.spec.whatwg.org/#comment-syntax
+            output.print(" ");
+        } else {
+            // the space is optional depending on "beautify"
+            output.space();
+        }
         self.right.print(output);
     });
     DEFPRINT(AST_Conditional, function(self, output){