Allow HTML comments on first line (#9760)
This commit is contained in:
parent
3aaafae053
commit
aaefc83a6c
@ -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);
|
||||
|
||||
1
packages/babel-parser/test/fixtures/comments/html/first-line/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/comments/html/first-line/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
/**/ --> comment
|
||||
102
packages/babel-parser/test/fixtures/comments/html/first-line/output.json
vendored
Normal file
102
packages/babel-parser/test/fixtures/comments/html/first-line/output.json
vendored
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user