Skip to content

Commit 0648804

Browse files
fix(runtime-core): correctly assign suspenseId to avoid conflicts with the default id (#9966)
close #9944
1 parent a47fb45 commit 0648804

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

packages/runtime-core/__tests__/components/Suspense.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ import {
2424
} from '@vue/runtime-test'
2525
import { createApp, defineComponent } from 'vue'
2626
import type { RawSlots } from 'packages/runtime-core/src/componentSlots'
27+
import { resetSuspenseId } from '../../src/components/Suspense'
2728

2829
describe('Suspense', () => {
2930
const deps: Promise<any>[] = []
3031

3132
beforeEach(() => {
3233
deps.length = 0
34+
resetSuspenseId()
3335
})
3436

3537
// a simple async factory for testing purposes only.

packages/runtime-core/src/components/Suspense.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ export const isSuspense = (type: any): boolean => type.__isSuspense
5050
// incrementing unique id for every pending branch
5151
let suspenseId = 0
5252

53+
/**
54+
* For testing only
55+
*/
56+
export const resetSuspenseId = () => (suspenseId = 0)
57+
5358
// Suspense exposes a component-like API, and is treated like a component
5459
// in the compiler, but internally it's a special built-in type that hooks
5560
// directly into the renderer.
@@ -476,7 +481,7 @@ function createSuspenseBoundary(
476481
hiddenContainer,
477482
anchor,
478483
deps: 0,
479-
pendingId: 0,
484+
pendingId: suspenseId++,
480485
timeout: typeof timeout === 'number' ? timeout : -1,
481486
activeBranch: null,
482487
pendingBranch: null,

packages/sfc-playground/src/App.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ onMounted(() => {
140140
:preview-options="{
141141
customCode: {
142142
importCode: `import { initCustomFormatter } from 'vue'`,
143-
useCode: `initCustomFormatter()`
144-
}
143+
useCode: `initCustomFormatter()`,
144+
},
145145
}"
146146
/>
147147
</template>

0 commit comments

Comments
 (0)