mirror of
				https://github.com/vuejs/babel-plugin-jsx.git
				synced 2025-10-31 09:22:19 +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) |       isConstant((property as any).value) | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|   if (t.isLiteral(node)) { |   if ( | ||||||
|  |     t.isTemplateLiteral(node) ? !node.expressions.length : t.isLiteral(node) | ||||||
|  |   ) { | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
|   return false; |   return false; | ||||||
|   | |||||||
| @@ -23,6 +23,14 @@ _createVNode("div", { | |||||||
| }, null, 6);" | }, 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`] = ` | exports[`Without JSX should work > Without JSX should work 1`] = ` | ||||||
| "import { createVNode } from 'vue'; | "import { createVNode } from 'vue'; | ||||||
| createVNode('div', null, ['Without JSX should work']);" | 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', |     name: 'using v-slots without children should not be spread', | ||||||
|     from: '<A v-slots={slots} />', |     from: '<A v-slots={slots} />', | ||||||
|   }, |   }, | ||||||
|  |   { | ||||||
|  |     name: 'TemplateLiteral prop and event co-usage', | ||||||
|  |     from: '<div value={`${foo}`} onClick={() => foo.value++}></div>', | ||||||
|  |   }, | ||||||
| ].forEach(({ name, from }) => { | ].forEach(({ name, from }) => { | ||||||
|   test(name, async () => { |   test(name, async () => { | ||||||
|     expect( |     expect( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user