@@ -104,45 +104,47 @@ export function createSlot(
104104 ? new Proxy ( rawProps , rawPropsProxyHandlers )
105105 : EMPTY_OBJ
106106
107+ let fragment : DynamicFragment
108+
107109 if ( isRef ( rawSlots . _ ) ) {
108- return instance . appContext . vapor ! . vdomSlot (
110+ fragment = instance . appContext . vapor ! . vdomSlot (
109111 rawSlots . _ ,
110112 name ,
111113 slotProps ,
112114 instance ,
113115 fallback ,
114116 )
115- }
117+ } else {
118+ fragment = __DEV__ ? new DynamicFragment ( 'slot' ) : new DynamicFragment ( )
119+ const isDynamicName = isFunction ( name )
120+ const renderSlot = ( ) => {
121+ const slot = getSlot ( rawSlots , isFunction ( name ) ? name ( ) : name )
122+ if ( slot ) {
123+ // create and cache bound version of the slot to make it stable
124+ // so that we avoid unnecessary updates if it resolves to the same slot
125+ fragment . update (
126+ slot . _bound ||
127+ ( slot . _bound = ( ) => {
128+ const slotContent = slot ( slotProps )
129+ if ( slotContent instanceof DynamicFragment ) {
130+ slotContent . fallback = fallback
131+ }
132+ return slotContent
133+ } ) ,
134+ )
135+ } else {
136+ fragment . update ( fallback )
137+ }
138+ }
116139
117- const isDynamicName = isFunction ( name )
118- const fragment = __DEV__ ? new DynamicFragment ( 'slot' ) : new DynamicFragment ( )
119- const renderSlot = ( ) => {
120- const slot = getSlot ( rawSlots , isFunction ( name ) ? name ( ) : name )
121- if ( slot ) {
122- // create and cache bound version of the slot to make it stable
123- // so that we avoid unnecessary updates if it resolves to the same slot
124- fragment . update (
125- slot . _bound ||
126- ( slot . _bound = ( ) => {
127- const slotContent = slot ( slotProps )
128- if ( slotContent instanceof DynamicFragment ) {
129- slotContent . fallback = fallback
130- }
131- return slotContent
132- } ) ,
133- )
140+ // dynamic slot name or has dynamicSlots
141+ if ( isDynamicName || rawSlots . $ ) {
142+ renderEffect ( renderSlot )
134143 } else {
135- fragment . update ( fallback )
144+ renderSlot ( )
136145 }
137146 }
138147
139- // dynamic slot name or has dynamicSlots
140- if ( isDynamicName || rawSlots . $ ) {
141- renderEffect ( renderSlot )
142- } else {
143- renderSlot ( )
144- }
145-
146148 if ( ! isHydrating && _insertionParent ) {
147149 insert ( fragment , _insertionParent , _insertionAnchor )
148150 }
0 commit comments