From: underfin <2218301630@qq.com> Date: Mon, 4 May 2020 14:41:48 +0000 (+0800) Subject: fix(transitionGroup): inner children should skip comment node (#1105) X-Git-Tag: v3.0.0-beta.8~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26a50ce67f64439cfc242fba59b1e7129e59ba40;p=thirdparty%2Fvuejs%2Fcore.git fix(transitionGroup): inner children should skip comment node (#1105) --- diff --git a/packages/runtime-dom/src/components/TransitionGroup.ts b/packages/runtime-dom/src/components/TransitionGroup.ts index aa8adf1437..734ba69343 100644 --- a/packages/runtime-dom/src/components/TransitionGroup.ts +++ b/packages/runtime-dom/src/components/TransitionGroup.ts @@ -101,7 +101,8 @@ const TransitionGroupImpl = { const cssTransitionProps = resolveTransitionProps(rawProps) const tag = rawProps.tag || Fragment prevChildren = children - children = getTransitionRawChildren(slots.default ? slots.default() : []) + const slotChildren = slots.default ? slots.default() : [] + children = getTransitionRawChildren(slotChildren) for (let i = 0; i < children.length; i++) { const child = children[i] @@ -110,7 +111,7 @@ const TransitionGroupImpl = { child, resolveTransitionHooks(child, cssTransitionProps, state, instance) ) - } else if (__DEV__ && child.type !== Comment) { + } else if (__DEV__) { warn(` children must be keyed.`) } } @@ -126,7 +127,7 @@ const TransitionGroupImpl = { } } - return createVNode(tag, null, children) + return createVNode(tag, null, slotChildren) } } } @@ -138,7 +139,9 @@ function getTransitionRawChildren(children: VNode[]): VNode[] { // handle fragment children case, e.g. v-for if (child.type === Fragment) { ret = ret.concat(getTransitionRawChildren(child.children as VNode[])) - } else { + } + // comment should be skip, e.g. v-if + if (child.type !== Comment) { ret.push(child) } }