From 10456fa75814d5bb0cd0e8d76e58046e27490ff7 Mon Sep 17 00:00:00 2001 From: yushangjiang <504427021@qq.com> Date: Tue, 25 Feb 2020 20:37:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(transformElement):=20sub-component=E2=80=98?= =?UTF-8?q?s=20direct=20child=20should=20openBlock=20(fix=20#766)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/compiler-core/src/transforms/transformElement.ts | 5 +++++ packages/runtime-core/src/helpers/renderSlot.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/compiler-core/src/transforms/transformElement.ts b/packages/compiler-core/src/transforms/transformElement.ts index 905268dee31..fe0a5afb7b9 100644 --- a/packages/compiler-core/src/transforms/transformElement.ts +++ b/packages/compiler-core/src/transforms/transformElement.ts @@ -134,6 +134,11 @@ export const transformElement: NodeTransform = (node, context) => { if (hasDynamicSlots) { patchFlag |= PatchFlags.DYNAMIC_SLOTS } + + // sub-component‘s direct child should openBlock + for (let i = 0; i < node.children.length; i++) { + node.children[i].codegenNode!.isBlock = true + } } else if (node.children.length === 1) { const child = node.children[0] const type = child.type diff --git a/packages/runtime-core/src/helpers/renderSlot.ts b/packages/runtime-core/src/helpers/renderSlot.ts index a6c2d47e7aa..eb16bc02200 100644 --- a/packages/runtime-core/src/helpers/renderSlot.ts +++ b/packages/runtime-core/src/helpers/renderSlot.ts @@ -35,7 +35,7 @@ export function renderSlot( Fragment, { key: props.key }, slot ? slot(props) : fallback || [], - slots._ ? PatchFlags.STABLE_FRAGMENT : PatchFlags.BAIL + slots._ ? 0 : PatchFlags.BAIL ) ) }