mirror of
				https://github.com/vuejs/babel-plugin-jsx.git
				synced 2025-11-01 01:42:21 +08:00 
			
		
		
		
	Merge pull request #729 from vuejs/fix-728
fix: exclude TemplateLiteral expression from isConstant
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
| @@ -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']);" | ||||
|   | ||||
| @@ -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( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user