fix(compiler-core): should attach key to single element child of <template v-for> (#1910)

This commit is contained in:
underfin
2020-08-20 22:09:57 +08:00
committed by GitHub
parent 7ffb79c563
commit 69cfed6b31
3 changed files with 43 additions and 0 deletions

View File

@@ -145,6 +145,9 @@ export const transformFor = createStructuralDirectiveTransform(
// but mark it as a block.
childBlock = (children[0] as PlainElementNode)
.codegenNode as VNodeCall
if (isTemplate && keyProperty) {
injectProp(childBlock, keyProperty, context)
}
childBlock.isBlock = !isStableFragment
if (childBlock.isBlock) {
helper(OPEN_BLOCK)