Skip to content

Commit

Permalink
fix(parser): allow regular expression in JSXExpressionContainer
Browse files Browse the repository at this point in the history
closes #204
  • Loading branch information
3cp committed Mar 18, 2022
1 parent 0fbf089 commit a5fcb80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/parser.ts
Expand Up @@ -9061,7 +9061,7 @@ function parseJSXExpressionContainer(
line: number,
column: number
): ESTree.JSXExpressionContainer | ESTree.JSXSpreadChild {
nextToken(parser, context);
nextToken(parser, context | Context.AllowRegExp);
const { tokenPos, linePos, colPos } = parser;
if (parser.token === Token.Ellipsis) return parseJSXSpreadChild(parser, context, tokenPos, linePos, colPos);

Expand Down
7 changes: 5 additions & 2 deletions test/parser/miscellaneous/jsx.ts
Expand Up @@ -18,7 +18,9 @@ describe('Miscellaneous - JSX', () => {
text
</>;`,
'<div>{this.props.children}</div>;',
'<a>{}</a>;'
'<a>{}</a>;',
'<p>{1/2}</p>',
'<p>{/w/.test(s)}</p>'
]) {
it(`${arg}`, () => {
t.doesNotThrow(() => {
Expand Down Expand Up @@ -105,7 +107,8 @@ describe('Miscellaneous - JSX', () => {
['[foo] > ;', Context.OptionsJSX],
['[foo] > ;', Context.OptionsJSX],
['[foo] > ;', Context.OptionsJSX],
['var x = <div>one</div>, <div>two</div>;', Context.OptionsJSX]
['var x = <div>one</div>, <div>two</div>;', Context.OptionsJSX],
['<p>{/}</p>', Context.OptionsJSX]
]);

pass('Miscellaneous - JSX (pass)', [
Expand Down

0 comments on commit a5fcb80

Please sign in to comment.