From 8cf6b5731d1399781fcb2a46a9134f2b30bce447 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 3 Feb 2020 20:47:41 -0500 Subject: [PATCH] test(compiler-ssr): v-for tests --- packages/compiler-core/src/transforms/vFor.ts | 13 +- .../compiler-ssr/__tests__/ssrVFor.spec.ts | 126 ++++++++++++++++++ .../compiler-ssr/__tests__/ssrVIf.spec.ts | 18 ++- .../compiler-ssr/src/transforms/ssrVFor.ts | 19 ++- .../compiler-ssr/src/transforms/ssrVIf.ts | 8 +- 5 files changed, 172 insertions(+), 12 deletions(-) create mode 100644 packages/compiler-ssr/__tests__/ssrVFor.spec.ts diff --git a/packages/compiler-core/src/transforms/vFor.ts b/packages/compiler-core/src/transforms/vFor.ts index 9081cb3f..d8a8fe1b 100644 --- a/packages/compiler-core/src/transforms/vFor.ts +++ b/packages/compiler-core/src/transforms/vFor.ts @@ -20,7 +20,8 @@ import { SlotOutletNode, ElementNode, DirectiveNode, - ForNode + ForNode, + PlainElementNode } from '../ast' import { createCompilerError, ErrorCodes } from '../errors' import { @@ -70,6 +71,9 @@ export const transformFor = createStructuralDirectiveTransform( // finish the codegen now that all children have been traversed let childBlock const isTemplate = isTemplateNode(node) + const { children } = forNode + const needFragmentWrapper = + children.length > 1 || children[0].type !== NodeTypes.ELEMENT const slotOutlet = isSlotOutlet(node) ? node : isTemplate && @@ -94,8 +98,8 @@ export const transformFor = createStructuralDirectiveTransform( // the props for renderSlot is passed as the 3rd argument. injectProp(childBlock, keyProperty, context) } - } else if (isTemplate) { - //