Comment,
isSameVNodeType,
VNode,
- VNodeArrayChildren
+ VNodeArrayChildren,
+ Fragment
} from '../vnode'
import { warn } from '../warning'
import { isKeepAlive } from './KeepAlive'
const state = useTransitionState()
return () => {
- const children = slots.default && slots.default()
+ const children = getTransitionRawChildren(
+ slots.default ? slots.default() : [],
+ true
+ )
if (!children || !children.length) {
return
}
vnode.transition = hooks
}
}
+
+export function getTransitionRawChildren(
+ children: VNode[],
+ keepComment: boolean = false
+): VNode[] {
+ let ret: VNode[] = []
+ for (let i = 0; i < children.length; i++) {
+ const child = children[i]
+ // handle fragment children case, e.g. v-for
+ if (child.type === Fragment) {
+ ret = ret.concat(
+ getTransitionRawChildren(child.children as VNode[], keepComment)
+ )
+ }
+ // comment placeholders should be skipped, e.g. v-if
+ else if (
+ child.type !== Comment ||
+ (child.type === Comment && keepComment)
+ ) {
+ ret.push(child)
+ }
+ }
+ return ret
+}
} from './Transition'
import {
Fragment,
- Comment,
VNode,
warn,
resolveTransitionHooks,
useTransitionState,
+ getTransitionRawChildren,
getCurrentInstance,
setTransitionHooks,
createVNode,
}
}
-function getTransitionRawChildren(children: VNode[]): VNode[] {
- let ret: VNode[] = []
- for (let i = 0; i < children.length; i++) {
- const child = children[i]
- // handle fragment children case, e.g. v-for
- if (child.type === Fragment) {
- ret = ret.concat(getTransitionRawChildren(child.children as VNode[]))
- }
- // comment placeholders should be skipped, e.g. v-if
- else if (child.type !== Comment) {
- ret.push(child)
- }
- }
- return ret
-}
-
// remove mode props as TransitionGroup doesn't support it
delete TransitionGroupImpl.props.mode