fix(transitionGroup): inner children should skip comment node (#1105)

This commit is contained in:
underfin 2020-05-04 22:41:48 +08:00 committed by GitHub
parent 3c60d40827
commit 26a50ce67f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(`<TransitionGroup> 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)
}
}