chore: tweaks
ci / test (push) Has been cancelled Details
ci / continuous-release (push) Has been cancelled Details

This commit is contained in:
daiwei 2025-07-25 22:15:47 +08:00
parent 92399d9f8f
commit 5b4673fccd
2 changed files with 6 additions and 22 deletions

View File

@ -98,9 +98,9 @@ export class DynamicFragment extends VaporFragment {
}
}
function setFragmentFallback(
export function setFragmentFallback(
fragment: VaporFragment,
fallback: BlockFn | undefined,
fallback: BlockFn,
): void {
// stop recursion if fragment has its own fallback
if (fragment.fallback) return

View File

@ -35,11 +35,11 @@ import {
} from './component'
import {
type Block,
DynamicFragment,
VaporFragment,
insert,
isFragment,
remove,
setFragmentFallback,
} from './block'
import { EMPTY_OBJ, extend, isArray, isFunction } from '@vue/shared'
import { type RawProps, rawPropsProxyHandlers } from './componentProps'
@ -116,22 +116,12 @@ const vaporInteropImpl: Omit<
const { slot, fallback } = n2.vs!
const propsRef = (n2.vs!.ref = shallowRef(n2.props))
const slotBlock = slot(new Proxy(propsRef, vaporSlotPropsProxyHandler))
// forwarded vdom slot without its own fallback, use the fallback provided by
// the slot outlet
if (slotBlock instanceof DynamicFragment) {
// vapor slot's nodes is a forwarded vdom slot
let nodes = slotBlock.nodes
while (isFragment(nodes)) {
ensureVDOMSlotFallback(nodes, fallback)
nodes = nodes.nodes
}
// handle nested fragments
if (fallback && isFragment(slotBlock)) {
setFragmentFallback(slotBlock, createFallback(fallback))
// use fragment's anchor when possible
selfAnchor = slotBlock.anchor
} else if (isFragment(slotBlock)) {
ensureVDOMSlotFallback(slotBlock, fallback)
selfAnchor = slotBlock.anchor!
}
if (!selfAnchor) selfAnchor = createTextNode()
insert((n2.el = n2.anchor = selfAnchor), container, anchor)
insert((n2.vb = slotBlock), container, selfAnchor)
@ -356,12 +346,6 @@ export const vaporInteropPlugin: Plugin = app => {
}) satisfies App['mount']
}
function ensureVDOMSlotFallback(block: VaporFragment, fallback?: () => any) {
if (block.insert && !block.fallback && fallback) {
block.fallback = createFallback(fallback)
}
}
const createFallback =
(fallback: () => any) =>
(