@@ -4,14 +4,14 @@ import {
44 createComponentInstance ,
55 currentInstance ,
66} from './component'
7- import { type Block , setupComponent } from './apiRender'
7+ import { setupComponent } from './apiRender'
88import {
99 type NormalizedRawProps ,
1010 type RawProps ,
1111 normalizeRawProps ,
1212 walkRawProps ,
1313} from './componentProps'
14- import type { RawSlots } from './componentSlots'
14+ import { type RawSlots , isDynamicSlotFn } from './componentSlots'
1515import { withAttrs } from './componentAttrs'
1616import { isString } from '@vue/shared'
1717import { renderEffect } from './renderEffect'
@@ -24,9 +24,9 @@ export function createComponent(
2424 slots : RawSlots | null = null ,
2525 singleRoot : boolean = false ,
2626 once : boolean = false ,
27- ) : ComponentInternalInstance {
27+ ) : ComponentInternalInstance | HTMLElement {
2828 if ( isString ( comp ) ) {
29- return fallbackComponent ( comp , rawProps , slots , singleRoot )
29+ return fallbackComponent ( comp , rawProps , slots )
3030 }
3131
3232 const current = currentInstance !
@@ -48,8 +48,7 @@ function fallbackComponent(
4848 comp : string ,
4949 rawProps : RawProps | null ,
5050 slots : RawSlots | null ,
51- singleRoot : boolean ,
52- ) {
51+ ) : HTMLElement {
5352 // eslint-disable-next-line no-restricted-globals
5453 const el = document . createElement ( comp )
5554
@@ -62,24 +61,16 @@ function fallbackComponent(
6261 } )
6362 }
6463
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 ) )
7971 }
80-
81- if ( block ) el . append ( ...normalizeBlock ( block ) )
82- } )
72+ }
8373 }
84- return { __return : el , rawProps }
74+
75+ return el
8576}
0 commit comments