Skip to content

Commit 4b24c73

Browse files
authored
Merge pull request #209 from meriyah/fix-jsx-regex
fix(parser): allow regular expression in JSXExpressionContainer
2 parents 0fbf089 + a5fcb80 commit 4b24c73

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9061,7 +9061,7 @@ function parseJSXExpressionContainer(
90619061
line: number,
90629062
column: number
90639063
): ESTree.JSXExpressionContainer | ESTree.JSXSpreadChild {
9064-
nextToken(parser, context);
9064+
nextToken(parser, context | Context.AllowRegExp);
90659065
const { tokenPos, linePos, colPos } = parser;
90669066
if (parser.token === Token.Ellipsis) return parseJSXSpreadChild(parser, context, tokenPos, linePos, colPos);
90679067

test/parser/miscellaneous/jsx.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ describe('Miscellaneous - JSX', () => {
1818
text
1919
</>;`,
2020
'<div>{this.props.children}</div>;',
21-
'<a>{}</a>;'
21+
'<a>{}</a>;',
22+
'<p>{1/2}</p>',
23+
'<p>{/w/.test(s)}</p>'
2224
]) {
2325
it(`${arg}`, () => {
2426
t.doesNotThrow(() => {
@@ -105,7 +107,8 @@ describe('Miscellaneous - JSX', () => {
105107
['[foo] > ;', Context.OptionsJSX],
106108
['[foo] > ;', Context.OptionsJSX],
107109
['[foo] > ;', Context.OptionsJSX],
108-
['var x = <div>one</div>, <div>two</div>;', Context.OptionsJSX]
110+
['var x = <div>one</div>, <div>two</div>;', Context.OptionsJSX],
111+
['<p>{/}</p>', Context.OptionsJSX]
109112
]);
110113

111114
pass('Miscellaneous - JSX (pass)', [

0 commit comments

Comments
 (0)