Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/runtime-dom/src/components/TransitionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.`)
}
}
Expand All @@ -126,7 +127,7 @@ const TransitionGroupImpl = {
}
}

return createVNode(tag, null, children)
return createVNode(tag, null, slotChildren)
}
}
}
Expand All @@ -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)
}
}
Expand Down