Skip to content

Commit 26a50ce

Browse files
authored
fix(transitionGroup): inner children should skip comment node (#1105)
1 parent 3c60d40 commit 26a50ce

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ const TransitionGroupImpl = {
101101
const cssTransitionProps = resolveTransitionProps(rawProps)
102102
const tag = rawProps.tag || Fragment
103103
prevChildren = children
104-
children = getTransitionRawChildren(slots.default ? slots.default() : [])
104+
const slotChildren = slots.default ? slots.default() : []
105+
children = getTransitionRawChildren(slotChildren)
105106

106107
for (let i = 0; i < children.length; i++) {
107108
const child = children[i]
@@ -110,7 +111,7 @@ const TransitionGroupImpl = {
110111
child,
111112
resolveTransitionHooks(child, cssTransitionProps, state, instance)
112113
)
113-
} else if (__DEV__ && child.type !== Comment) {
114+
} else if (__DEV__) {
114115
warn(`<TransitionGroup> children must be keyed.`)
115116
}
116117
}
@@ -126,7 +127,7 @@ const TransitionGroupImpl = {
126127
}
127128
}
128129

129-
return createVNode(tag, null, children)
130+
return createVNode(tag, null, slotChildren)
130131
}
131132
}
132133
}
@@ -138,7 +139,9 @@ function getTransitionRawChildren(children: VNode[]): VNode[] {
138139
// handle fragment children case, e.g. v-for
139140
if (child.type === Fragment) {
140141
ret = ret.concat(getTransitionRawChildren(child.children as VNode[]))
141-
} else {
142+
}
143+
// comment should be skip, e.g. v-if
144+
if (child.type !== Comment) {
142145
ret.push(child)
143146
}
144147
}

0 commit comments

Comments
 (0)