|
@@ -54,6 +54,27 @@ export const transformFor = createStructuralDirectiveTransform(
|
|
|
forNode.source
|
|
forNode.source
|
|
|
]) as ForRenderListExpression
|
|
]) as ForRenderListExpression
|
|
|
const keyProp = findProp(node, `key`)
|
|
const keyProp = findProp(node, `key`)
|
|
|
|
|
+ const keyProperty = keyProp
|
|
|
|
|
+ ? createObjectProperty(
|
|
|
|
|
+ `key`,
|
|
|
|
|
+ keyProp.type === NodeTypes.ATTRIBUTE
|
|
|
|
|
+ ? createSimpleExpression(keyProp.value!.content, true)
|
|
|
|
|
+ : keyProp.exp!
|
|
|
|
|
+ )
|
|
|
|
|
+ : null
|
|
|
|
|
+
|
|
|
|
|
+ if (!__BROWSER__ && context.prefixIdentifiers && keyProperty) {
|
|
|
|
|
+ // #2085 process :key expression needs to be processed in order for it
|
|
|
|
|
+ // to behave consistently for <template v-for> and <div v-for>.
|
|
|
|
|
+ // In the case of `<template v-for>`, the node is discarded and never
|
|
|
|
|
+ // traversed so its key expression won't be processed by the normal
|
|
|
|
|
+ // transforms.
|
|
|
|
|
+ keyProperty.value = processExpression(
|
|
|
|
|
+ keyProperty.value as SimpleExpressionNode,
|
|
|
|
|
+ context
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const isStableFragment =
|
|
const isStableFragment =
|
|
|
forNode.source.type === NodeTypes.SIMPLE_EXPRESSION &&
|
|
forNode.source.type === NodeTypes.SIMPLE_EXPRESSION &&
|
|
|
forNode.source.isConstant
|
|
forNode.source.isConstant
|
|
@@ -108,14 +129,7 @@ export const transformFor = createStructuralDirectiveTransform(
|
|
|
isSlotOutlet(node.children[0])
|
|
isSlotOutlet(node.children[0])
|
|
|
? (node.children[0] as SlotOutletNode) // api-extractor somehow fails to infer this
|
|
? (node.children[0] as SlotOutletNode) // api-extractor somehow fails to infer this
|
|
|
: null
|
|
: null
|
|
|
- const keyProperty = keyProp
|
|
|
|
|
- ? createObjectProperty(
|
|
|
|
|
- `key`,
|
|
|
|
|
- keyProp.type === NodeTypes.ATTRIBUTE
|
|
|
|
|
- ? createSimpleExpression(keyProp.value!.content, true)
|
|
|
|
|
- : keyProp.exp!
|
|
|
|
|
- )
|
|
|
|
|
- : null
|
|
|
|
|
|
|
+
|
|
|
if (slotOutlet) {
|
|
if (slotOutlet) {
|
|
|
// <slot v-for="..."> or <template v-for="..."><slot/></template>
|
|
// <slot v-for="..."> or <template v-for="..."><slot/></template>
|
|
|
childBlock = slotOutlet.codegenNode as RenderSlotCall
|
|
childBlock = slotOutlet.codegenNode as RenderSlotCall
|