Skip to content

Commit

Permalink
fix(TransitionGroup): should collect raw children with Fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Apr 25, 2020
1 parent 0bb1f67 commit 0442ce4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/runtime-dom/src/components/TransitionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,7 @@ const TransitionGroupImpl = {
const cssTransitionProps = resolveTransitionProps(rawProps)
const tag = rawProps.tag || Fragment
prevChildren = children
children = slots.default ? slots.default() : []

// handle fragment children case, e.g. v-for
if (children.length === 1 && children[0].type === Fragment) {
children = children[0].children as VNode[]
}
children = getTransitionRawChildren(slots.default ? slots.default() : [])

for (let i = 0; i < children.length; i++) {
const child = children[i]
Expand Down Expand Up @@ -136,6 +131,20 @@ const TransitionGroupImpl = {
}
}

function getTransitionRawChildren(children: VNode[]): VNode[] {
let array: VNode[] = []
for (const child of children) {
const { type, children } = child
// handle fragment children case, e.g. v-for
if (type === Fragment) {
array = array.concat(getTransitionRawChildren(children as VNode[]))
} else {
array.push(child)
}
}
return array
}

// remove mode props as TransitionGroup doesn't support it
delete TransitionGroupImpl.props.mode

Expand Down

0 comments on commit 0442ce4

Please sign in to comment.