1
- import { defineComponent , computed , CSSProperties , Fragment , Comment , isVNode } from 'vue' ;
1
+ import { defineComponent , computed , CSSProperties , Fragment , isVNode , Teleport } from 'vue' ;
2
2
import props from './props' ;
3
3
import { usePrefixClass } from '../hooks/useConfig' ;
4
4
import { useTNodeJSX } from '../hooks/tnode' ;
5
- import { useChildSlots } from '../hooks/slot' ;
5
+ import { useChildSlots , useFlatChildrenSlots } from '../hooks/slot' ;
6
6
import { isNumber } from 'lodash-es' ;
7
7
import { isString } from 'lodash-es' ;
8
8
import { isArray } from 'lodash-es' ;
@@ -23,6 +23,7 @@ export default defineComponent({
23
23
const COMPONENT_NAME = usePrefixClass ( 'space' ) ;
24
24
const renderTNodeJSX = useTNodeJSX ( ) ;
25
25
const getChildSlots = useChildSlots ( ) ;
26
+ const getFlatChildren = useFlatChildrenSlots ( ) ;
26
27
27
28
const needPolyfill = computed ( ( ) => props . forceFlexGapPolyfill || defaultNeedPolyfill ) ;
28
29
@@ -52,22 +53,21 @@ export default defineComponent({
52
53
}
53
54
return style ;
54
55
} ) ;
55
-
56
56
function renderChildren ( ) {
57
- const children = getChildSlots ( ) ;
57
+ const children = getFlatChildren ( getChildSlots ( ) ) ;
58
58
const separatorContent = renderTNodeJSX ( 'separator' ) ;
59
- return children
60
- . filter ( ( child ) => ( isVNode ( child ) ? child . type !== Comment : true ) )
61
- . map ( ( child , index ) => {
62
- // filter last child
63
- const showSeparator = index + 1 !== children . length && separatorContent ;
64
- return (
65
- < Fragment >
66
- < div class = { `${ COMPONENT_NAME . value } -item` } > { child } </ div >
67
- { showSeparator && < div class = { `${ COMPONENT_NAME . value } -item-separator` } > { separatorContent } </ div > }
68
- </ Fragment >
69
- ) ;
70
- } ) ;
59
+ return children . map ( ( child , index ) => {
60
+ const isTeleport = isVNode ( child ) && child . type === Teleport ;
61
+ if ( isTeleport ) return null ;
62
+ // filter last child
63
+ const showSeparator = index + 1 !== children . length && separatorContent ;
64
+ return (
65
+ < Fragment >
66
+ < div class = { `${ COMPONENT_NAME . value } -item` } > { child } </ div >
67
+ { showSeparator && < div class = { `${ COMPONENT_NAME . value } -item-separator` } > { separatorContent } </ div > }
68
+ </ Fragment >
69
+ ) ;
70
+ } ) ;
71
71
}
72
72
73
73
return ( ) => {
0 commit comments