Skip to content

Commit

Permalink
Allow HTML comments on first line (#9760)
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed Mar 25, 2019
1 parent 3aaafae commit aaefc83
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/babel-parser/src/tokenizer/index.js
Expand Up @@ -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);
Expand Down
@@ -0,0 +1 @@
/**/ --> comment
@@ -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
}
}
}
]
}

0 comments on commit aaefc83

Please sign in to comment.