|
@@ -47,6 +47,7 @@ import {
|
|
|
import { processExpression } from './transformExpression'
|
|
import { processExpression } from './transformExpression'
|
|
|
import { validateBrowserExpression } from '../validateExpression'
|
|
import { validateBrowserExpression } from '../validateExpression'
|
|
|
import { PatchFlagNames, PatchFlags } from '@vue/shared'
|
|
import { PatchFlagNames, PatchFlags } from '@vue/shared'
|
|
|
|
|
+import { transformBindShorthand } from './vBind'
|
|
|
|
|
|
|
|
export const transformFor = createStructuralDirectiveTransform(
|
|
export const transformFor = createStructuralDirectiveTransform(
|
|
|
'for',
|
|
'for',
|
|
@@ -60,13 +61,20 @@ export const transformFor = createStructuralDirectiveTransform(
|
|
|
]) as ForRenderListExpression
|
|
]) as ForRenderListExpression
|
|
|
const isTemplate = isTemplateNode(node)
|
|
const isTemplate = isTemplateNode(node)
|
|
|
const memo = findDir(node, 'memo')
|
|
const memo = findDir(node, 'memo')
|
|
|
- const keyProp = findProp(node, `key`)
|
|
|
|
|
|
|
+ const keyProp = findProp(node, `key`, false, true)
|
|
|
|
|
+ if (keyProp && keyProp.type === NodeTypes.DIRECTIVE && !keyProp.exp) {
|
|
|
|
|
+ // resolve :key shorthand #10882
|
|
|
|
|
+ transformBindShorthand(keyProp, context)
|
|
|
|
|
+ }
|
|
|
const keyExp =
|
|
const keyExp =
|
|
|
keyProp &&
|
|
keyProp &&
|
|
|
(keyProp.type === NodeTypes.ATTRIBUTE
|
|
(keyProp.type === NodeTypes.ATTRIBUTE
|
|
|
- ? createSimpleExpression(keyProp.value!.content, true)
|
|
|
|
|
- : keyProp.exp!)
|
|
|
|
|
- const keyProperty = keyProp ? createObjectProperty(`key`, keyExp!) : null
|
|
|
|
|
|
|
+ ? keyProp.value
|
|
|
|
|
+ ? createSimpleExpression(keyProp.value.content, true)
|
|
|
|
|
+ : undefined
|
|
|
|
|
+ : keyProp.exp)
|
|
|
|
|
+ const keyProperty =
|
|
|
|
|
+ keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null
|
|
|
|
|
|
|
|
if (!__BROWSER__ && isTemplate) {
|
|
if (!__BROWSER__ && isTemplate) {
|
|
|
// #2085 / #5288 process :key and v-memo expressions need to be
|
|
// #2085 / #5288 process :key and v-memo expressions need to be
|