Allow HTML comments on first line (#9760)

This commit is contained in:
Daniel Tschinder 2019-03-25 14:22:57 -07:00 committed by GitHub
parent 3aaafae053
commit aaefc83a6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 107 additions and 1 deletions

View File

@ -526,7 +526,10 @@ export default class Tokenizer extends LocationParser {
next === charCodes.dash &&
!this.inModule &&
this.input.charCodeAt(this.state.pos + 2) === charCodes.greaterThan &&
lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.pos))
(this.state.lastTokEnd === 0 ||
lineBreak.test(
this.input.slice(this.state.lastTokEnd, this.state.pos),
))
) {
// A `-->` line comment
this.skipLineComment(3);

View File

@ -0,0 +1 @@
/**/ --> comment

View File

@ -0,0 +1,102 @@
{
"type": "File",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"program": {
"type": "Program",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"sourceType": "script",
"interpreter": null,
"body": [],
"directives": [],
"innerComments": [
{
"type": "CommentBlock",
"value": "",
"start": 0,
"end": 4,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 4
}
}
},
{
"type": "CommentLine",
"value": " comment",
"start": 5,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 16
}
}
}
]
},
"comments": [
{
"type": "CommentBlock",
"value": "",
"start": 0,
"end": 4,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 4
}
}
},
{
"type": "CommentLine",
"value": " comment",
"start": 5,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 16
}
}
}
]
}