@@ -4,14 +4,14 @@ import {
4
4
createComponentInstance ,
5
5
currentInstance ,
6
6
} from './component'
7
- import { type Block , setupComponent } from './apiRender'
7
+ import { setupComponent } from './apiRender'
8
8
import {
9
9
type NormalizedRawProps ,
10
10
type RawProps ,
11
11
normalizeRawProps ,
12
12
walkRawProps ,
13
13
} from './componentProps'
14
- import type { RawSlots } from './componentSlots'
14
+ import { type RawSlots , isDynamicSlotFn } from './componentSlots'
15
15
import { withAttrs } from './componentAttrs'
16
16
import { isString } from '@vue/shared'
17
17
import { renderEffect } from './renderEffect'
@@ -24,9 +24,9 @@ export function createComponent(
24
24
slots : RawSlots | null = null ,
25
25
singleRoot : boolean = false ,
26
26
once : boolean = false ,
27
- ) : ComponentInternalInstance {
27
+ ) : ComponentInternalInstance | HTMLElement {
28
28
if ( isString ( comp ) ) {
29
- return fallbackComponent ( comp , rawProps , slots , singleRoot )
29
+ return fallbackComponent ( comp , rawProps , slots )
30
30
}
31
31
32
32
const current = currentInstance !
@@ -48,8 +48,7 @@ function fallbackComponent(
48
48
comp : string ,
49
49
rawProps : RawProps | null ,
50
50
slots : RawSlots | null ,
51
- singleRoot : boolean ,
52
- ) {
51
+ ) : HTMLElement {
53
52
// eslint-disable-next-line no-restricted-globals
54
53
const el = document . createElement ( comp )
55
54
@@ -62,24 +61,16 @@ function fallbackComponent(
62
61
} )
63
62
}
64
63
65
- if ( slots && slots . length ) {
66
- renderEffect ( ( ) => {
67
- let block : Block | undefined
68
-
69
- if ( slots && slots . default ) {
70
- block = slots . default ( )
71
- } else {
72
- for ( const slotFn of dynamicSlots ! ) {
73
- const slot = slotFn ( )
74
- if ( slot . name === 'default' ) {
75
- block = slot . fn ( )
76
- break
77
- }
78
- }
64
+ if ( slots ) {
65
+ if ( ! Array . isArray ( slots ) ) slots = [ slots ]
66
+ for ( let i = 0 ; i < slots . length ; i ++ ) {
67
+ const slot = slots [ i ]
68
+ if ( ! isDynamicSlotFn ( slot ) && slot . default ) {
69
+ const block = slot . default && slot . default ( )
70
+ if ( block ) el . append ( ...normalizeBlock ( block ) )
79
71
}
80
-
81
- if ( block ) el . append ( ...normalizeBlock ( block ) )
82
- } )
72
+ }
83
73
}
84
- return { __return : el , rawProps }
74
+
75
+ return el
85
76
}
0 commit comments