mirror of https://github.com/vuejs/core.git
chore: tweaks
This commit is contained in:
parent
92399d9f8f
commit
5b4673fccd
|
@ -98,9 +98,9 @@ export class DynamicFragment extends VaporFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFragmentFallback(
|
export function setFragmentFallback(
|
||||||
fragment: VaporFragment,
|
fragment: VaporFragment,
|
||||||
fallback: BlockFn | undefined,
|
fallback: BlockFn,
|
||||||
): void {
|
): void {
|
||||||
// stop recursion if fragment has its own fallback
|
// stop recursion if fragment has its own fallback
|
||||||
if (fragment.fallback) return
|
if (fragment.fallback) return
|
||||||
|
|
|
@ -35,11 +35,11 @@ import {
|
||||||
} from './component'
|
} from './component'
|
||||||
import {
|
import {
|
||||||
type Block,
|
type Block,
|
||||||
DynamicFragment,
|
|
||||||
VaporFragment,
|
VaporFragment,
|
||||||
insert,
|
insert,
|
||||||
isFragment,
|
isFragment,
|
||||||
remove,
|
remove,
|
||||||
|
setFragmentFallback,
|
||||||
} from './block'
|
} from './block'
|
||||||
import { EMPTY_OBJ, extend, isArray, isFunction } from '@vue/shared'
|
import { EMPTY_OBJ, extend, isArray, isFunction } from '@vue/shared'
|
||||||
import { type RawProps, rawPropsProxyHandlers } from './componentProps'
|
import { type RawProps, rawPropsProxyHandlers } from './componentProps'
|
||||||
|
@ -116,22 +116,12 @@ const vaporInteropImpl: Omit<
|
||||||
const { slot, fallback } = n2.vs!
|
const { slot, fallback } = n2.vs!
|
||||||
const propsRef = (n2.vs!.ref = shallowRef(n2.props))
|
const propsRef = (n2.vs!.ref = shallowRef(n2.props))
|
||||||
const slotBlock = slot(new Proxy(propsRef, vaporSlotPropsProxyHandler))
|
const slotBlock = slot(new Proxy(propsRef, vaporSlotPropsProxyHandler))
|
||||||
// forwarded vdom slot without its own fallback, use the fallback provided by
|
// handle nested fragments
|
||||||
// the slot outlet
|
if (fallback && isFragment(slotBlock)) {
|
||||||
if (slotBlock instanceof DynamicFragment) {
|
setFragmentFallback(slotBlock, createFallback(fallback))
|
||||||
// vapor slot's nodes is a forwarded vdom slot
|
|
||||||
let nodes = slotBlock.nodes
|
|
||||||
while (isFragment(nodes)) {
|
|
||||||
ensureVDOMSlotFallback(nodes, fallback)
|
|
||||||
nodes = nodes.nodes
|
|
||||||
}
|
|
||||||
// use fragment's anchor when possible
|
// use fragment's anchor when possible
|
||||||
selfAnchor = slotBlock.anchor
|
selfAnchor = slotBlock.anchor
|
||||||
} else if (isFragment(slotBlock)) {
|
|
||||||
ensureVDOMSlotFallback(slotBlock, fallback)
|
|
||||||
selfAnchor = slotBlock.anchor!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selfAnchor) selfAnchor = createTextNode()
|
if (!selfAnchor) selfAnchor = createTextNode()
|
||||||
insert((n2.el = n2.anchor = selfAnchor), container, anchor)
|
insert((n2.el = n2.anchor = selfAnchor), container, anchor)
|
||||||
insert((n2.vb = slotBlock), container, selfAnchor)
|
insert((n2.vb = slotBlock), container, selfAnchor)
|
||||||
|
@ -356,12 +346,6 @@ export const vaporInteropPlugin: Plugin = app => {
|
||||||
}) satisfies App['mount']
|
}) satisfies App['mount']
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureVDOMSlotFallback(block: VaporFragment, fallback?: () => any) {
|
|
||||||
if (block.insert && !block.fallback && fallback) {
|
|
||||||
block.fallback = createFallback(fallback)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const createFallback =
|
const createFallback =
|
||||||
(fallback: () => any) =>
|
(fallback: () => any) =>
|
||||||
(
|
(
|
||||||
|
|
Loading…
Reference in New Issue