var ret = make_string(str, quote);
if (options.inline_script)
ret = ret.replace(/<\x2fscript([>\/\t\n\f\r ])/gi, "<\\/script$1");
+ ret = ret.replace(/\x3c!--/g, "\\x3c!--");
+ ret = ret.replace(/--\x3e/g, "--\\x3e");
return ret;
};
});
DEFPRINT(AST_Binary, function(self, output){
self.left.print(output);
- output.space();
+ if (self.operator == ">"
+ && self.left instanceof AST_UnaryPostfix
+ && self.left.operator == "--") {
+ // space is mandatory to avoid outputting -->
+ output.print(" ");
+ } else {
+ // the space is optional depending on "beautify"
+ output.space();
+ }
output.print(self.operator);
if (self.operator == "<"
&& self.right instanceof AST_UnaryPrefix
&& 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"
--- /dev/null
+html_comment_in_expression: {
+ input: {
+ function f(a, b, x, y) { return a < !--b && x-- > y; }
+ }
+ expect_exact: "function f(a,b,x,y){return a< !--b&&x-- >y}";
+}
+
+html_comment_in_string_literal: {
+ input: {
+ function f() { return "<!--HTML-->comment in<!--string literal-->"; }
+ }
+ expect_exact: 'function f(){return"\\x3c!--HTML--\\x3ecomment in\\x3c!--string literal--\\x3e"}';
+}
+
+