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