Skip to content

Commit 8aca259

Browse files
committed
wip: vdom slot interop
1 parent dcf927f commit 8aca259

File tree

7 files changed

+1144
-32
lines changed

7 files changed

+1144
-32
lines changed

packages/runtime-core/src/helpers/renderSlot.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ export function renderSlot(
8181
}
8282
openBlock()
8383
const validSlotContent = slot && ensureValidVNode(slot(props))
84+
85+
// handle forwarded vapor slot fallback
86+
ensureVaporSlotFallback(validSlotContent, fallback)
87+
8488
const slotKey =
8589
props.key ||
8690
// slot content array of a dynamic conditional slot may have a branch
@@ -124,3 +128,20 @@ export function ensureValidVNode(
124128
? vnodes
125129
: null
126130
}
131+
132+
export function ensureVaporSlotFallback(
133+
vnodes: VNodeArrayChildren | null | undefined,
134+
fallback?: () => VNodeArrayChildren,
135+
): void {
136+
let vaporSlot: any
137+
if (
138+
vnodes &&
139+
vnodes.length === 1 &&
140+
isVNode(vnodes[0]) &&
141+
(vaporSlot = vnodes[0].vs)
142+
) {
143+
if (!vaporSlot.fallback && fallback) {
144+
vaporSlot.fallback = fallback
145+
}
146+
}
147+
}

packages/runtime-core/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,3 +557,7 @@ export { startMeasure, endMeasure } from './profiling'
557557
* @internal
558558
*/
559559
export { initFeatureFlags } from './featureFlags'
560+
/**
561+
* @internal
562+
*/
563+
export { ensureVaporSlotFallback } from './helpers/renderSlot'

packages/runtime-core/src/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2622,7 +2622,7 @@ export function traverseStaticChildren(
26222622
function locateNonHydratedAsyncRoot(
26232623
instance: ComponentInternalInstance,
26242624
): ComponentInternalInstance | undefined {
2625-
const subComponent = instance.subTree.component
2625+
const subComponent = instance.vapor ? null : instance.subTree.component
26262626
if (subComponent) {
26272627
if (subComponent.asyncDep && !subComponent.asyncResolved) {
26282628
return subComponent

0 commit comments

Comments
 (0)