Skip to content
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

Missing tokens for JSXText #216

Open
golopot opened this issue Apr 8, 2022 · 1 comment
Open

Missing tokens for JSXText #216

golopot opened this issue Apr 8, 2022 · 1 comment

Comments

@golopot
Copy link

golopot commented Apr 8, 2022

When parsing this JSX,

<a>123</a>

, there is no token corresponding to 123.

Code:

const meriyah = require("meriyah");

const tokens = [];
const source = `<a>123</a>`;
const ast = meriyah.parse(source, {
  jsx:true,
  onToken(type, start, end, loc) {
    tokens.push({
      type,
      value: source.slice(start, end),
      range: [start, end],
    });
  },
});

console.dir(tokens, {depth: null});

Actual output:

[
  { type: 'Punctuator', value: '<', range: [ 0, 1 ] },
  { type: 'Identifier', value: 'a', range: [ 1, 2 ] },
  { type: 'Punctuator', value: '>', range: [ 2, 3 ] },
  { type: 'Identifier', value: 'a', range: [ 8, 9 ] },
  { type: 'Punctuator', value: '>', range: [ 9, 10 ] }
]

Expected:
The 123 part appears somewhere in the tokens.

@3cp
Copy link
Member

3cp commented Apr 9, 2022

Lots of tokens in jsx didn't go through standard nextToken(). There should be more missing in some other cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants