1
1
import { EMPTY_OBJ , NO , hasOwn , isArray , isFunction } from '@vue/shared'
2
- import {
3
- type Block ,
4
- type BlockFn ,
5
- DynamicFragment ,
6
- type VaporFragment ,
7
- insert ,
8
- isFragment ,
9
- } from './block'
2
+ import { type Block , type BlockFn , DynamicFragment , insert } from './block'
10
3
import { rawPropsProxyHandlers } from './componentProps'
11
4
import { currentInstance , isRef } from '@vue/runtime-dom'
12
5
import type { LooseRawProps , VaporComponentInstance } from './component'
@@ -144,34 +137,16 @@ export function createSlot(
144
137
const renderSlot = ( ) => {
145
138
const slot = getSlot ( rawSlots , isFunction ( name ) ? name ( ) : name )
146
139
if ( slot ) {
140
+ fragment . fallback = fallback
147
141
// create and cache bound version of the slot to make it stable
148
142
// so that we avoid unnecessary updates if it resolves to the same slot
149
143
fragment . update (
150
144
slot . _bound ||
151
145
( slot . _bound = ( ) => {
152
146
const slotContent = slot ( slotProps )
153
147
if ( slotContent instanceof DynamicFragment ) {
154
- let nodes = slotContent . nodes
155
- if (
156
- ( slotContent . fallback = fallback ) &&
157
- isArray ( nodes ) &&
158
- nodes . length === 0
159
- ) {
160
- // use fallback if the slot content is invalid
161
- slotContent . update ( fallback )
162
- } else {
163
- while ( isFragment ( nodes ) ) {
164
- ensureVaporSlotFallback ( nodes , fallback )
165
- nodes = nodes . nodes
166
- }
167
- }
168
- }
169
- // forwarded vdom slot, if there is no fallback provide, try use the fallback
170
- // provided by the slot outlet.
171
- else if ( isFragment ( slotContent ) ) {
172
- ensureVaporSlotFallback ( slotContent , fallback )
148
+ slotContent . fallback = fallback
173
149
}
174
-
175
150
return slotContent
176
151
} ) ,
177
152
)
@@ -194,12 +169,3 @@ export function createSlot(
194
169
195
170
return fragment
196
171
}
197
-
198
- function ensureVaporSlotFallback (
199
- block : VaporFragment ,
200
- fallback ?: VaporSlot ,
201
- ) : void {
202
- if ( block . insert && ! block . fallback && fallback ) {
203
- block . fallback = fallback
204
- }
205
- }
0 commit comments