]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: save
authordaiwei <daiwei521@126.com>
Mon, 19 May 2025 08:33:05 +0000 (16:33 +0800)
committerdaiwei <daiwei521@126.com>
Mon, 19 May 2025 09:24:55 +0000 (17:24 +0800)
packages/runtime-core/src/apiCreateApp.ts
packages/runtime-core/src/component.ts
packages/runtime-core/src/components/Suspense.ts
packages/runtime-core/src/renderer.ts
packages/runtime-vapor/src/component.ts
packages/runtime-vapor/src/vdomInterop.ts

index f9208014c4c82772ca51795abebc77c2f454e1ce..31e8ee85df711c708d5dab48fb4b8033f95ebb42 100644 (file)
@@ -183,7 +183,6 @@ export interface VaporInteropInterface {
     anchor: any,
     parentComponent: ComponentInternalInstance | null,
     parentSuspense: SuspenseBoundary | null,
-    isSingleRoot?: boolean,
   ): GenericComponentInstance // VaporComponentInstance
   update(n1: VNode, n2: VNode, shouldUpdate: boolean): void
   unmount(vnode: VNode, doRemove?: boolean): void
index 86fc717eb2d91b634f9faf723ff9a536d438d272..849173ac7a5897e570d1fbf223eb530d25f5abcc 100644 (file)
@@ -939,7 +939,7 @@ function setupStatefulComponent(
         // bail here and wait for re-entry.
         instance.asyncDep = setupResult
         if (__DEV__ && !instance.suspense) {
-          const name = Component.name ?? 'Anonymous'
+          const name = getComponentName(Component) ?? 'Anonymous'
           warn(
             `Component <${name}>: setup function returned a promise, but no ` +
               `<Suspense> boundary was found in the parent component tree. ` +
index 205e234d7a835eb5d4235053975c36031fd4aa4b..e4a76c63ff70375073b17dfd829c85214da593dd 100644 (file)
@@ -714,7 +714,9 @@ function createSuspenseBoundary(
           if (instance.vapor) {
             // @ts-expect-error
             setupRenderEffect(asyncSetupResult)
-          } else {
+          }
+          // vdom component
+          else {
             const { vnode } = instance
             if (__DEV__) {
               pushWarningContext(vnode)
index 423eeb971a5ea00793aaa336a1572636a5509f8f..5930d6d5111860f93c1ea4e6ca02ee1bd3a56290 100644 (file)
@@ -2387,24 +2387,6 @@ function baseCreateRenderer(
       instance.isUnmounted = true
     }, parentSuspense)
 
-    // A component with async dep inside a pending suspense is unmounted before
-    // its async dep resolves. This should remove the dep from the suspense, and
-    // cause the suspense to resolve immediately if that was the last dep.
-    if (
-      __FEATURE_SUSPENSE__ &&
-      parentSuspense &&
-      parentSuspense.pendingBranch &&
-      !parentSuspense.isUnmounted &&
-      instance.asyncDep &&
-      !instance.asyncResolved &&
-      instance.suspenseId === parentSuspense.pendingId
-    ) {
-      parentSuspense.deps--
-      if (parentSuspense.deps === 0) {
-        parentSuspense.resolve()
-      }
-    }
-
     if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
       devtoolsComponentRemoved(instance)
     }
@@ -2426,7 +2408,7 @@ function baseCreateRenderer(
   const getNextHostNode: NextFn = vnode => {
     if (vnode.shapeFlag & ShapeFlags.COMPONENT) {
       if ((vnode.type as ConcreteComponent).__vapor) {
-        return hostNextSibling((vnode.component! as any).block)
+        return hostNextSibling(vnode.anchor!)
       }
       return getNextHostNode(vnode.component!.subTree)
     }
index 05ddfe8806130c3617743dc3ff39bf737d532813..f82ae268291e236478ecb1cabedd3b0be71a2d82 100644 (file)
@@ -217,22 +217,27 @@ export function createComponent(
     : EMPTY_OBJ
 
   const isAsyncSetup = isPromise(setupResult)
-  if (__FEATURE_SUSPENSE__ && isAsyncSetup) {
-    // async setup returned Promise.
-    // bail here and wait for re-entry.
-    instance.asyncDep = setupResult
-    if (__DEV__ && !instance.suspense) {
-      const name = getComponentName(component, true) ?? 'Anonymous'
+  if (isAsyncSetup) {
+    if (__FEATURE_SUSPENSE__) {
+      // async setup returned Promise.
+      // bail here and wait for re-entry.
+      instance.asyncDep = setupResult
+      if (__DEV__ && !instance.suspense) {
+        const name = getComponentName(component) ?? 'Anonymous'
+        warn(
+          `Component <${name}>: setup function returned a promise, but no ` +
+            `<Suspense> boundary was found in the parent component tree. ` +
+            `A component with async setup() must be nested in a <Suspense> ` +
+            `in order to be rendered.`,
+        )
+      }
+    } else if (__DEV__) {
       warn(
-        `Component <${name}>: setup function returned a promise, but no ` +
-          `<Suspense> boundary was found in the parent component tree. ` +
-          `A component with async setup() must be nested in a <Suspense> ` +
-          `in order to be rendered.`,
+        `setup() returned a Promise, but the version of Vue you are using ` +
+          `does not support it yet.`,
       )
     }
-  }
-
-  if (!isAsyncSetup) {
+  } else {
     handleSetupResult(setupResult, component, instance, isSingleRoot, setupFn)
   }
 
@@ -532,8 +537,8 @@ export function handleSetupResult(
   setupResult: any,
   component: VaporComponent,
   instance: VaporComponentInstance,
-  isSingleRoot: boolean | undefined,
-  setupFn: VaporSetupFn | undefined,
+  isSingleRoot?: boolean,
+  setupFn?: VaporSetupFn,
 ): void {
   if (__DEV__) {
     pushWarningContext(instance)
index 373be8b653d33d9406a1112d496bb7b9a731c522..8269b201722ee6f287a347134fee88c647a3f24a 100644 (file)
@@ -40,14 +40,7 @@ const vaporInteropImpl: Omit<
   VaporInteropInterface,
   'vdomMount' | 'vdomUnmount' | 'vdomSlot'
 > = {
-  mount(
-    vnode,
-    container,
-    anchor,
-    parentComponent,
-    parentSuspense,
-    isSingleRoot,
-  ) {
+  mount(vnode, container, anchor, parentComponent, parentSuspense) {
     const selfAnchor = (vnode.el = vnode.anchor = createTextNode())
     container.insertBefore(selfAnchor, anchor)
     const prev = currentInstance
@@ -66,28 +59,27 @@ const vaporInteropImpl: Omit<
       {
         _: slotsRef, // pass the slots ref
       } as any as RawSlots,
-      isSingleRoot,
+      undefined,
       undefined,
       parentSuspense,
     ))
     instance.rawPropsRef = propsRef
     instance.rawSlotsRef = slotsRef
-    if (__FEATURE_SUSPENSE__ && instance.asyncDep) {
-      parentSuspense &&
-        parentSuspense.registerDep(
-          instance as any,
-          setupResult => {
-            handleSetupResult(
-              setupResult,
-              component,
-              instance,
-              isSingleRoot,
-              isFunction(component) ? component : component.setup,
-            )
-            mountComponent(instance, container, selfAnchor)
-          },
-          false,
-        )
+    if (__FEATURE_SUSPENSE__ && parentSuspense && instance.asyncDep) {
+      parentSuspense.registerDep(
+        instance as any,
+        (setupResult: any) => {
+          handleSetupResult(
+            setupResult,
+            component,
+            instance,
+            undefined,
+            isFunction(component) ? component : component.setup,
+          )
+          mountComponent(instance, container, selfAnchor)
+        },
+        false,
+      )
     } else {
       mountComponent(instance, container, selfAnchor)
     }