Skip to content

ast: Incomplete HTML entity handling for JSXText and JSXAttributeValue #9667

@leaysgur

Description

@leaysgur

I found 2 mismatches in the AST of JSX generated by ESTree-compatible parsers such as Acorn(+acorn-jsx).

  • (1) The JSXText node does not have a raw property
  • (2) Neither JSXAttributeValue nor JSXText processes HTML entities

For (1), the solution is simply to add the property. The value should be the same as that of a StringLiteral, using the Span position.

👉🏻 UPDATE: (1) is now fixed in #9641


For (2), the situation is a bit more complex, adjustments are needed for:

  • The value of JSXAttributeValue::StringLiteral
  • The value of JSXText

In these cases, it is necessary to assign the value with HTML entities resolved.

http://facebook.github.io/jsx/#sec-jsx-JSXString-SV

Currently, OXC seems to handle this in a transformer following TypeScript?

However, to output an AST identical to Acorn(+arcorn-jsx), this needs to be performed during the parsing.

Image

Metadata

Metadata

Assignees

Labels

A-astArea - AST

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions