]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: fix h signature for suspense
authorEvan You <yyx990803@gmail.com>
Tue, 29 Oct 2019 18:04:44 +0000 (14:04 -0400)
committerEvan You <yyx990803@gmail.com>
Tue, 29 Oct 2019 18:04:53 +0000 (14:04 -0400)
packages/runtime-core/src/h.ts
packages/runtime-core/src/suspense.ts
packages/runtime-core/src/vnode.ts

index eebee3684aed2cd1e1998f9d9c4011b9f3d67740..b7a9ff49998a4d536f0d347ce235a5e15ad79de6 100644 (file)
@@ -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>(
index 2a7019c79cc38117dedb7b2ff46b5f1a41767000..bda5ae075ca2eb1ac49c90b072ef86e47759f751 100644 (file)
@@ -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()
         })
       }
 
index cf8c4e5eb2d281bb466d59426efb458e42f31fde..882ba059ad3f13bfe66368ac18d6f355602fd5ca 100644 (file)
@@ -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 =