|
|
@@ -104,45 +104,47 @@ export function createSlot(
|
|
|
? new Proxy(rawProps, rawPropsProxyHandlers)
|
|
|
: EMPTY_OBJ
|
|
|
|
|
|
+ let fragment: DynamicFragment
|
|
|
+
|
|
|
if (isRef(rawSlots._)) {
|
|
|
- return instance.appContext.vapor!.vdomSlot(
|
|
|
+ fragment = instance.appContext.vapor!.vdomSlot(
|
|
|
rawSlots._,
|
|
|
name,
|
|
|
slotProps,
|
|
|
instance,
|
|
|
fallback,
|
|
|
)
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ fragment = __DEV__ ? new DynamicFragment('slot') : new DynamicFragment()
|
|
|
+ const isDynamicName = isFunction(name)
|
|
|
+ const renderSlot = () => {
|
|
|
+ const slot = getSlot(rawSlots, isFunction(name) ? name() : name)
|
|
|
+ if (slot) {
|
|
|
+ // create and cache bound version of the slot to make it stable
|
|
|
+ // so that we avoid unnecessary updates if it resolves to the same slot
|
|
|
+ fragment.update(
|
|
|
+ slot._bound ||
|
|
|
+ (slot._bound = () => {
|
|
|
+ const slotContent = slot(slotProps)
|
|
|
+ if (slotContent instanceof DynamicFragment) {
|
|
|
+ slotContent.fallback = fallback
|
|
|
+ }
|
|
|
+ return slotContent
|
|
|
+ }),
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ fragment.update(fallback)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- const isDynamicName = isFunction(name)
|
|
|
- const fragment = __DEV__ ? new DynamicFragment('slot') : new DynamicFragment()
|
|
|
- const renderSlot = () => {
|
|
|
- const slot = getSlot(rawSlots, isFunction(name) ? name() : name)
|
|
|
- if (slot) {
|
|
|
- // create and cache bound version of the slot to make it stable
|
|
|
- // so that we avoid unnecessary updates if it resolves to the same slot
|
|
|
- fragment.update(
|
|
|
- slot._bound ||
|
|
|
- (slot._bound = () => {
|
|
|
- const slotContent = slot(slotProps)
|
|
|
- if (slotContent instanceof DynamicFragment) {
|
|
|
- slotContent.fallback = fallback
|
|
|
- }
|
|
|
- return slotContent
|
|
|
- }),
|
|
|
- )
|
|
|
+ // dynamic slot name or has dynamicSlots
|
|
|
+ if (isDynamicName || rawSlots.$) {
|
|
|
+ renderEffect(renderSlot)
|
|
|
} else {
|
|
|
- fragment.update(fallback)
|
|
|
+ renderSlot()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // dynamic slot name or has dynamicSlots
|
|
|
- if (isDynamicName || rawSlots.$) {
|
|
|
- renderEffect(renderSlot)
|
|
|
- } else {
|
|
|
- renderSlot()
|
|
|
- }
|
|
|
-
|
|
|
if (!isHydrating && _insertionParent) {
|
|
|
insert(fragment, _insertionParent, _insertionAnchor)
|
|
|
}
|