diff --git a/packages/babel-plugin-jsx/src/utils.ts b/packages/babel-plugin-jsx/src/utils.ts index 6e1d24de..b8c9a2b5 100644 --- a/packages/babel-plugin-jsx/src/utils.ts +++ b/packages/babel-plugin-jsx/src/utils.ts @@ -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; diff --git a/packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap b/packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap index 3ffb6738..fe97df98 100644 --- a/packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap +++ b/packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap @@ -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']);" diff --git a/packages/babel-plugin-jsx/test/snapshot.test.ts b/packages/babel-plugin-jsx/test/snapshot.test.ts index 407da6ea..e1488fd2 100644 --- a/packages/babel-plugin-jsx/test/snapshot.test.ts +++ b/packages/babel-plugin-jsx/test/snapshot.test.ts @@ -208,6 +208,10 @@ const transpile = (source: string, options: VueJSXPluginOptions = {}) => name: 'using v-slots without children should not be spread', from: '', }, + { + name: 'TemplateLiteral prop and event co-usage', + from: '
foo.value++}>
', + }, ].forEach(({ name, from }) => { test(name, async () => { expect(