Skip to content

Commit 8ed3455

Browse files
authored
fix(transition-group): should collect raw children with Fragment (#1046)
fix #1045
1 parent ba240eb commit 8ed3455

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

packages/runtime-dom/src/components/TransitionGroup.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,7 @@ const TransitionGroupImpl = {
101101
const cssTransitionProps = resolveTransitionProps(rawProps)
102102
const tag = rawProps.tag || Fragment
103103
prevChildren = children
104-
children = slots.default ? slots.default() : []
105-
106-
// handle fragment children case, e.g. v-for
107-
if (children.length === 1 && children[0].type === Fragment) {
108-
children = children[0].children as VNode[]
109-
}
104+
children = getTransitionRawChildren(slots.default ? slots.default() : [])
110105

111106
for (let i = 0; i < children.length; i++) {
112107
const child = children[i]
@@ -136,6 +131,20 @@ const TransitionGroupImpl = {
136131
}
137132
}
138133

134+
function getTransitionRawChildren(children: VNode[]): VNode[] {
135+
let ret: VNode[] = []
136+
for (let i = 0; i < children.length; i++) {
137+
const child = children[i]
138+
// handle fragment children case, e.g. v-for
139+
if (child.type === Fragment) {
140+
ret = ret.concat(getTransitionRawChildren(child.children as VNode[]))
141+
} else {
142+
ret.push(child)
143+
}
144+
}
145+
return ret
146+
}
147+
139148
// remove mode props as TransitionGroup doesn't support it
140149
delete TransitionGroupImpl.props.mode
141150

0 commit comments

Comments
 (0)