New issue
Advanced search Search tips

Issue 920367 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Syntax highlighting and autocompletion is confused by HTML comments in JavaScript

Reported by jeremybanks.ca@gmail.com, Jan 9

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/20100101 Firefox/64.0

Steps to reproduce the problem:
1. Paste the following into the console:

console.log("This is executed (A)"); <!-- This is a line comment.
--> This is also a line comment. Even if I add this: /* 
console.log("This is executed (B)"); 

2. Observe that line 3 is highlighted as though it was a comment.
3. Press enter, and observe that line 3 is executed, because it is not actually a comment.

4. Create an HTML document containing the following.

<script>
console.log("This is executed (A)"); <!-- This is a line comment.
--> This is also a line comment. Even if I add this: /* 
console.log("This is executed (B)"); 
</script>

5. Open the HTML document in Chrome.
6. Open the Developer Console, and observe that both log lines were executed.
7. Open the Element Inspector, and observe that the contents of the script tax are incorrectly highlighted, as they were in (2).

What is the expected behavior?

What went wrong?
As described in ECMAScript 9 Appendix B Section 1.3, <!-- and --> should function sort-of like // line comments (with minor grammar differences) in a non-module web context. The parser used by v8 itself recognize these constructs. (Including in Node, where perhaps it shouldn't, but that's a subject for a different forum.)

However, Chrome's developer tools do not recognize this syntax, and fail to parse the code correctly when it is present.

In addition to affecting highlighting, this also causes autocompletion to misbehave. It offers suggestions inside the comment on line 2, because it thinks it's code, and it does not offering suggestions on line 3, because it thinks it's a comment.

Did this work before? No 

Chrome version: 71.0.3578.98 (Official Build) (64-bit)  Channel: n/a
OS Version: OS X 10.14
Flash Version:
 
not a comment.png
66.9 KB View Download
Owner: l...@chromium.org
Status: Assigned (was: Unconfirmed)

Sign in to add a comment