Skip to content

Commit 642275f

Browse files
authored
Allow yielding JSX without parenthesis (#115)
1 parent 4242df8 commit 642275f

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function getJsxTokens(acorn) {
2727
const tokTypes = {
2828
jsxName: new TokenType('jsxName'),
2929
jsxText: new TokenType('jsxText', {beforeExpr: true}),
30-
jsxTagStart: new TokenType('jsxTagStart'),
30+
jsxTagStart: new TokenType('jsxTagStart', {startsExpr: true}),
3131
jsxTagEnd: new TokenType('jsxTagEnd')
3232
};
3333

test/tests-jsx.js

+71
Original file line numberDiff line numberDiff line change
@@ -4634,3 +4634,74 @@ test('<A>foo&gt;</A>', {
46344634
}
46354635
]
46364636
});
4637+
test('function*it(){yield <a></a>}', {
4638+
"type": "Program",
4639+
"start": 0,
4640+
"end": 28,
4641+
"body": [
4642+
{
4643+
"type": "FunctionDeclaration",
4644+
"start": 0,
4645+
"end": 28,
4646+
"id": {
4647+
"type": "Identifier",
4648+
"start": 9,
4649+
"end": 11,
4650+
"name": "it"
4651+
},
4652+
"expression": false,
4653+
"generator": true,
4654+
"async": false,
4655+
"params": [],
4656+
"body": {
4657+
"type": "BlockStatement",
4658+
"start": 13,
4659+
"end": 28,
4660+
"body": [
4661+
{
4662+
"type": "ExpressionStatement",
4663+
"start": 14,
4664+
"end": 27,
4665+
"expression": {
4666+
"type": "YieldExpression",
4667+
"start": 14,
4668+
"end": 27,
4669+
"delegate": false,
4670+
"argument": {
4671+
"type": "JSXElement",
4672+
"start": 20,
4673+
"end": 27,
4674+
"openingElement": {
4675+
"type": "JSXOpeningElement",
4676+
"start": 20,
4677+
"end": 23,
4678+
"attributes": [],
4679+
"name": {
4680+
"type": "JSXIdentifier",
4681+
"start": 21,
4682+
"end": 22,
4683+
"name": "a"
4684+
},
4685+
"selfClosing": false
4686+
},
4687+
"closingElement": {
4688+
"type": "JSXClosingElement",
4689+
"start": 23,
4690+
"end": 27,
4691+
"name": {
4692+
"type": "JSXIdentifier",
4693+
"start": 25,
4694+
"end": 26,
4695+
"name": "a"
4696+
}
4697+
},
4698+
"children": []
4699+
}
4700+
}
4701+
}
4702+
]
4703+
}
4704+
}
4705+
],
4706+
"sourceType": "script"
4707+
});

0 commit comments

Comments
 (0)