mirror of https://github.com/vuejs/core.git
fix(runtime-core): correctly assign suspenseId to avoid conflicts with the default id (#9966)
close #9944
This commit is contained in:
parent
a47fb45c50
commit
06488047c1
|
@ -24,12 +24,14 @@ import {
|
||||||
} from '@vue/runtime-test'
|
} from '@vue/runtime-test'
|
||||||
import { createApp, defineComponent } from 'vue'
|
import { createApp, defineComponent } from 'vue'
|
||||||
import type { RawSlots } from 'packages/runtime-core/src/componentSlots'
|
import type { RawSlots } from 'packages/runtime-core/src/componentSlots'
|
||||||
|
import { resetSuspenseId } from '../../src/components/Suspense'
|
||||||
|
|
||||||
describe('Suspense', () => {
|
describe('Suspense', () => {
|
||||||
const deps: Promise<any>[] = []
|
const deps: Promise<any>[] = []
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
deps.length = 0
|
deps.length = 0
|
||||||
|
resetSuspenseId()
|
||||||
})
|
})
|
||||||
|
|
||||||
// a simple async factory for testing purposes only.
|
// a simple async factory for testing purposes only.
|
||||||
|
|
|
@ -50,6 +50,11 @@ export const isSuspense = (type: any): boolean => type.__isSuspense
|
||||||
// incrementing unique id for every pending branch
|
// incrementing unique id for every pending branch
|
||||||
let suspenseId = 0
|
let suspenseId = 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For testing only
|
||||||
|
*/
|
||||||
|
export const resetSuspenseId = () => (suspenseId = 0)
|
||||||
|
|
||||||
// Suspense exposes a component-like API, and is treated like a component
|
// 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
|
// in the compiler, but internally it's a special built-in type that hooks
|
||||||
// directly into the renderer.
|
// directly into the renderer.
|
||||||
|
@ -476,7 +481,7 @@ function createSuspenseBoundary(
|
||||||
hiddenContainer,
|
hiddenContainer,
|
||||||
anchor,
|
anchor,
|
||||||
deps: 0,
|
deps: 0,
|
||||||
pendingId: 0,
|
pendingId: suspenseId++,
|
||||||
timeout: typeof timeout === 'number' ? timeout : -1,
|
timeout: typeof timeout === 'number' ? timeout : -1,
|
||||||
activeBranch: null,
|
activeBranch: null,
|
||||||
pendingBranch: null,
|
pendingBranch: null,
|
||||||
|
|
|
@ -140,8 +140,8 @@ onMounted(() => {
|
||||||
:preview-options="{
|
:preview-options="{
|
||||||
customCode: {
|
customCode: {
|
||||||
importCode: `import { initCustomFormatter } from 'vue'`,
|
importCode: `import { initCustomFormatter } from 'vue'`,
|
||||||
useCode: `initCustomFormatter()`
|
useCode: `initCustomFormatter()`,
|
||||||
}
|
},
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue