diff --git a/Units/parser-html.r/comment-in-js.d/args.ctags b/Units/parser-html.r/comment-in-js.d/args.ctags
new file mode 100644
index 0000000000..9e1788d634
--- /dev/null
+++ b/Units/parser-html.r/comment-in-js.d/args.ctags
@@ -0,0 +1,3 @@
+--sort=no
+--fields=+l
+--extras=+g
diff --git a/Units/parser-html.r/comment-in-js.d/expected.tags b/Units/parser-html.r/comment-in-js.d/expected.tags
new file mode 100644
index 0000000000..60b76d4741
--- /dev/null
+++ b/Units/parser-html.r/comment-in-js.d/expected.tags
@@ -0,0 +1,5 @@
+simple_anchor input.html /^ <\/a>$/;" a language:HTML
+unquoted_anchor input.html /^ <\/a>$/;" a language:HTML
+prefixed_anchor input.html /^ <\/a>$/;" a language:HTML
+postfixed_anchor input.html /^ <\/a>$/;" a language:HTML
+message input.html /^function message()$/;" f language:JavaScript
diff --git a/Units/parser-html.r/comment-in-js.d/input.html b/Units/parser-html.r/comment-in-js.d/input.html
new file mode 100644
index 0000000000..1ce895e255
--- /dev/null
+++ b/Units/parser-html.r/comment-in-js.d/input.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/parsers/html.c b/parsers/html.c
index 8d40e2ee8e..4cacc6ee3a 100644
--- a/parsers/html.c
+++ b/parsers/html.c
@@ -334,23 +334,26 @@ static void readToken (tokenInfo *const token, bool skipComments, bool asJSX)
d = getcFromInputFile ();
if (d == '-')
{
- int e = ' ';
- int f = ' ';
- do
+ /* JSX does not support HTML comments, so don't skip
+ * over them */
+ if (!asJSX)
{
- d = e;
- e = f;
- f = getcFromInputFile ();
+ int e = ' ';
+ int f = ' ';
+ do
+ {
+ d = e;
+ e = f;
+ f = getcFromInputFile ();
+ }
+ while (f != EOF && ! (d == '-' && e == '-' && f == '>'));
+
+ if (skipComments)
+ goto getNextChar;
}
- while (f != EOF && ! (d == '-' && e == '-' && f == '>'));
- if (skipComments)
- goto getNextChar;
- else
- {
- token->type = TOKEN_COMMENT;
- break;
- }
+ token->type = TOKEN_COMMENT;
+ break;
}
}
ungetcToInputFile (d);
@@ -843,7 +846,7 @@ extern void htmlParseJSXElement (void)
tokenInfo token;
token.string = vStringNew ();
- readToken (&token, true, true);
+ readToken (&token, false, true);
if (token.type == TOKEN_OPEN_TAG_START)
readTag (&token, NULL, 0, true);