fix: fix h signature for suspense
This commit is contained in:
parent
ea2e2ce5bd
commit
083296ead6
@ -5,7 +5,8 @@ import {
|
||||
VNodeChildren,
|
||||
Fragment,
|
||||
Portal,
|
||||
isVNode
|
||||
isVNode,
|
||||
Suspense
|
||||
} from './vnode'
|
||||
import { isObject, isArray } from '@vue/shared'
|
||||
import { Ref } from '@vue/reactivity'
|
||||
@ -102,6 +103,19 @@ export function h(
|
||||
children?: RawChildren
|
||||
): VNode
|
||||
|
||||
// suspense
|
||||
export function h(type: typeof Suspense, children?: RawChildren): VNode
|
||||
export function h(
|
||||
type: typeof Suspense,
|
||||
props?:
|
||||
| (RawProps & {
|
||||
onResolve?: () => void
|
||||
onRecede?: () => void
|
||||
})
|
||||
| null,
|
||||
children?: RawChildren | RawSlots
|
||||
): VNode
|
||||
|
||||
// functional component
|
||||
export function h(type: FunctionalComponent, children?: RawChildren): VNode
|
||||
export function h<P>(
|
||||
|
@ -196,7 +196,7 @@ export interface SuspenseBoundary<
|
||||
isUnmounted: boolean
|
||||
effects: Function[]
|
||||
resolve(): void
|
||||
restart(): void
|
||||
recede(): void
|
||||
move(container: HostElement, anchor: HostNode | null): void
|
||||
next(): HostNode | null
|
||||
registerDep(
|
||||
@ -315,7 +315,7 @@ function createSuspenseBoundary<HostNode, HostElement>(
|
||||
}
|
||||
},
|
||||
|
||||
restart() {
|
||||
recede() {
|
||||
suspense.isResolved = false
|
||||
const {
|
||||
vnode,
|
||||
@ -349,10 +349,10 @@ function createSuspenseBoundary<HostNode, HostElement>(
|
||||
updateHOCHostEl(parentComponent, el)
|
||||
}
|
||||
|
||||
// invoke @suspense event
|
||||
const onSuspense = vnode.props && vnode.props.onSuspense
|
||||
if (isFunction(onSuspense)) {
|
||||
onSuspense()
|
||||
// invoke @recede event
|
||||
const onRecede = vnode.props && vnode.props.onRecede
|
||||
if (isFunction(onRecede)) {
|
||||
onRecede()
|
||||
}
|
||||
},
|
||||
|
||||
@ -377,7 +377,7 @@ function createSuspenseBoundary<HostNode, HostElement>(
|
||||
// suspense tree
|
||||
if (suspense.isResolved) {
|
||||
queueJob(() => {
|
||||
suspense.restart()
|
||||
suspense.recede()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,9 @@ export const Portal = Symbol(__DEV__ ? 'Portal' : undefined)
|
||||
export const Text = Symbol(__DEV__ ? 'Text' : undefined)
|
||||
export const Comment = Symbol(__DEV__ ? 'Comment' : undefined)
|
||||
|
||||
const Suspense = __FEATURE_SUSPENSE__ ? SuspenseImpl : null
|
||||
const Suspense = (__FEATURE_SUSPENSE__
|
||||
? SuspenseImpl
|
||||
: null) as typeof SuspenseImpl
|
||||
export { Suspense }
|
||||
|
||||
export type VNodeTypes =
|
||||
|
Loading…
Reference in New Issue
Block a user