Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/babel-plugin-jsx/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ export const isConstant = (
isConstant((property as any).value)
);
}
if (t.isLiteral(node)) {
if (
t.isTemplateLiteral(node) ? !node.expressions.length : t.isLiteral(node)
) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ _createVNode("div", {
}, null, 6);"
`;

exports[`TemplateLiteral prop and event co-usage > TemplateLiteral prop and event co-usage 1`] = `
"import { createVNode as _createVNode } from "vue";
_createVNode("div", {
"value": \`\${foo}\`,
"onClick": () => foo.value++
}, null, 8, ["value", "onClick"]);"
`;

exports[`Without JSX should work > Without JSX should work 1`] = `
"import { createVNode } from 'vue';
createVNode('div', null, ['Without JSX should work']);"
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-plugin-jsx/test/snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ const transpile = (source: string, options: VueJSXPluginOptions = {}) =>
name: 'using v-slots without children should not be spread',
from: '<A v-slots={slots} />',
},
{
name: 'TemplateLiteral prop and event co-usage',
from: '<div value={`${foo}`} onClick={() => foo.value++}></div>',
},
].forEach(({ name, from }) => {
test(name, async () => {
expect(
Expand Down
Loading