Allow placeholders in JSXElements when parsing templates (#7583)
This commit is contained in:
parent
840ba187a7
commit
f98dff9189
@ -64,7 +64,7 @@ function placeholderVisitorHandler(
|
||||
state: MetadataState,
|
||||
) {
|
||||
let name;
|
||||
if (t.isIdentifier(node)) {
|
||||
if (t.isIdentifier(node) || t.isJSXIdentifier(node)) {
|
||||
name = ((node: any): BabelNodeIdentifier).name;
|
||||
} else if (t.isStringLiteral(node)) {
|
||||
name = ((node: any): BabelNodeStringLiteral).value;
|
||||
|
||||
@ -204,5 +204,20 @@ describe("@babel/template", function() {
|
||||
expect(result.test.type).to.equal("BinaryExpression");
|
||||
expect(result.test.left).to.equal(value);
|
||||
});
|
||||
|
||||
it("should replace JSX placeholder", () => {
|
||||
const result = template.expression(
|
||||
`
|
||||
<TAG>{'content'}</TAG>
|
||||
`,
|
||||
{
|
||||
plugins: ["jsx"],
|
||||
},
|
||||
)({
|
||||
TAG: t.jsxIdentifier("div"),
|
||||
});
|
||||
|
||||
expect(generator(result).code).to.equal("<div>{'content'}</div>");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user