-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comment ranges at wrong location #104
Comments
@3cp Didn't you solve this before so this could work with ESCodegen? |
It was #83. Fixed start of non-comment token. I will have a look of comment, the range of comment is not constructed by a token. I think I noticed something wrong with comment before. But didn't pay too much attention because it didn't affect my use cases. |
We set start for comment after But this is not the only issue here. In our ast tree, the finally block (in ast node, not the onToken) has wrong start, it should start at @KFlash why we have html comment? for jsx? But why it('should extract html comments in array', () => {
const arr: any[] = [];
parseScript('<!--comment #1\n--> comment #2', {
onComment: arr,
webcompat: true
});
t.deepEqual(arr, [
{
type: 'HTMLOpen',
value: 'comment #1\n'
},
{
type: 'HTMLClose',
value: ' comment #2'
}
]);
}); |
HTML comment is part of the AnnexB extension. Same as other parsers. HTML comment skips either |
That's a weird spec, it's different from comment in html format. Since the spec says
I will make the start of HTMClose comment before "\n-->"
|
Try to run the following code in e.g. RunKit:
If you then compare the ranges in the comment array for both Meriyah and Esprima, then you will see the values are not the same (start is 2 under, end is 1 under). If you then look at the generated code, which are generated from the Meriyah and Esprima tree and compare them, then you will see the comments are placed at the wrong places from the Meriyah tree.
Generated code from Esprima tree
Generated code from Meriyah tree
-Thomas
The text was updated successfully, but these errors were encountered: