Skip to content

Commit

Permalink
fix: parsing of JSXText following JSXSpreadChild (#14974)
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
liuxingbaoyu committed Sep 24, 2022
1 parent 7c6ecb5 commit 6be6e04
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/babel-parser/src/plugins/jsx/index.ts
Expand Up @@ -354,7 +354,7 @@ export default (superClass: typeof Parser) =>
jsxParseSpreadChild(node: Undone<N.JSXSpreadChild>): N.JSXSpreadChild {
this.next(); // ellipsis
node.expression = this.parseExpression();
this.setContext(tc.j_oTag);
this.setContext(tc.j_expr);
this.state.canStartJSXElement = true;
this.expect(tt.braceR);

Expand Down
@@ -0,0 +1 @@
<a>{ ...b }c</a>
@@ -0,0 +1,61 @@
{
"type": "File",
"start":0,"end":16,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":16,"index":16}},
"program": {
"type": "Program",
"start":0,"end":16,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":16,"index":16}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":16,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":16,"index":16}},
"expression": {
"type": "JSXElement",
"start":0,"end":16,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":16,"index":16}},
"openingElement": {
"type": "JSXOpeningElement",
"start":0,"end":3,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":3,"index":3}},
"name": {
"type": "JSXIdentifier",
"start":1,"end":2,"loc":{"start":{"line":1,"column":1,"index":1},"end":{"line":1,"column":2,"index":2}},
"name": "a"
},
"attributes": [],
"selfClosing": false
},
"closingElement": {
"type": "JSXClosingElement",
"start":12,"end":16,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":16,"index":16}},
"name": {
"type": "JSXIdentifier",
"start":14,"end":15,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":15,"index":15}},
"name": "a"
}
},
"children": [
{
"type": "JSXSpreadChild",
"start":3,"end":11,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":11,"index":11}},
"expression": {
"type": "Identifier",
"start":8,"end":9,"loc":{"start":{"line":1,"column":8,"index":8},"end":{"line":1,"column":9,"index":9},"identifierName":"b"},
"name": "b"
}
},
{
"type": "JSXText",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11,"index":11},"end":{"line":1,"column":12,"index":12}},
"extra": {
"rawValue": "c",
"raw": "c"
},
"value": "c"
}
]
}
}
],
"directives": []
}
}

0 comments on commit 6be6e04

Please sign in to comment.