]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): correctly assign suspenseId to avoid conflicts with the default...
authoryangxiuxiu <79584569+RicardoErii@users.noreply.github.com>
Wed, 3 Jan 2024 09:22:06 +0000 (17:22 +0800)
committerGitHub <noreply@github.com>
Wed, 3 Jan 2024 09:22:06 +0000 (17:22 +0800)
close #9944

packages/runtime-core/__tests__/components/Suspense.spec.ts
packages/runtime-core/src/components/Suspense.ts
packages/sfc-playground/src/App.vue

index f8f2064ebbddcc5aa630e5022d18b031dc384e2e..203937aa52607b3692cde16af06cd25ed036aacd 100644 (file)
@@ -24,12 +24,14 @@ import {
 } from '@vue/runtime-test'
 import { createApp, defineComponent } from 'vue'
 import type { RawSlots } from 'packages/runtime-core/src/componentSlots'
+import { resetSuspenseId } from '../../src/components/Suspense'
 
 describe('Suspense', () => {
   const deps: Promise<any>[] = []
 
   beforeEach(() => {
     deps.length = 0
+    resetSuspenseId()
   })
 
   // a simple async factory for testing purposes only.
index 411ef054ca14493db341fcfd4e3f2358c4bb00b9..01aeb6188b28935b71dbfbf3bae3b2052c5658d7 100644 (file)
@@ -50,6 +50,11 @@ export const isSuspense = (type: any): boolean => type.__isSuspense
 // incrementing unique id for every pending branch
 let suspenseId = 0
 
+/**
+ * For testing only
+ */
+export const resetSuspenseId = () => (suspenseId = 0)
+
 // Suspense exposes a component-like API, and is treated like a component
 // in the compiler, but internally it's a special built-in type that hooks
 // directly into the renderer.
@@ -476,7 +481,7 @@ function createSuspenseBoundary(
     hiddenContainer,
     anchor,
     deps: 0,
-    pendingId: 0,
+    pendingId: suspenseId++,
     timeout: typeof timeout === 'number' ? timeout : -1,
     activeBranch: null,
     pendingBranch: null,
index 200ac550d8fc0478c81d7c048be18b85417ffdf5..cadd39f4baa6a322bfe96c46ed31c1bc3dcf96ac 100644 (file)
@@ -140,8 +140,8 @@ onMounted(() => {
     :preview-options="{
       customCode: {
         importCode: `import { initCustomFormatter } from 'vue'`,
-        useCode: `initCustomFormatter()`
-      }
+        useCode: `initCustomFormatter()`,
+      },
     }"
   />
 </template>