From a27e9ee9aea3487ef3ef0c8a5df53227fc172886 Mon Sep 17 00:00:00 2001 From: likui <2218301630@qq.com> Date: Wed, 8 Apr 2020 21:32:09 +0800 Subject: [PATCH] fix(runtime-core): set fragment root children should also update dynamicChildren (#944) fix #943 --- packages/runtime-core/src/componentRenderUtils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index 709ee85986c..aec309446ec 100644 --- a/packages/runtime-core/src/componentRenderUtils.ts +++ b/packages/runtime-core/src/componentRenderUtils.ts @@ -163,6 +163,7 @@ const getChildRoot = ( return [vnode, undefined] } const rawChildren = vnode.children as VNodeArrayChildren + const dynamicChildren = vnode.dynamicChildren as VNodeArrayChildren const children = rawChildren.filter(child => { return !(isVNode(child) && child.type === Comment) }) @@ -171,7 +172,13 @@ const getChildRoot = ( } const childRoot = children[0] const index = rawChildren.indexOf(childRoot) - const setRoot = (updatedRoot: VNode) => (rawChildren[index] = updatedRoot) + const dynamicIndex = dynamicChildren + ? dynamicChildren.indexOf(childRoot) + : null + const setRoot = (updatedRoot: VNode) => { + rawChildren[index] = updatedRoot + if (dynamicIndex !== null) dynamicChildren[dynamicIndex] = updatedRoot + } return [normalizeVNode(childRoot), setRoot] }