Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj committed Dec 7, 2024
1 parent f08cdca commit 37057c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/babel-plugin-jsx/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export const isConstant = (
isConstant((property as any).value)
);
}
if (t.isLiteral(node) && !t.isTemplateLiteral(node)) {
if (!t.isTemplateLiteral(node) && 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

0 comments on commit 37057c4

Please sign in to comment.