diff --git a/packages/runtime-core/__tests__/hmr.spec.ts b/packages/runtime-core/__tests__/hmr.spec.ts index 3f157d009..2831293f5 100644 --- a/packages/runtime-core/__tests__/hmr.spec.ts +++ b/packages/runtime-core/__tests__/hmr.spec.ts @@ -894,4 +894,56 @@ describe('hot module replacement', () => { await timeout() expect(serializeInner(root)).toBe('
bar
') }) + + test('multi reload child wrapped in Suspense + KeepAlive', async () => { + const id = 'test-child-reload-3' + const Child: ComponentOptions = { + __hmrId: id, + setup() { + const count = ref(0) + return { count } + }, + render: compileToFunction(`
{{ count }}
`), + } + createRecord(id, Child) + + const appId = 'test-app-id' + const App: ComponentOptions = { + __hmrId: appId, + components: { Child }, + render: compileToFunction(` + + + + + + `), + } + + const root = nodeOps.createElement('div') + render(h(App), root) + expect(serializeInner(root)).toBe('
0
') + await timeout() + reload(id, { + __hmrId: id, + setup() { + const count = ref(1) + return { count } + }, + render: compileToFunction(`
{{ count }}
`), + }) + await timeout() + expect(serializeInner(root)).toBe('
1
') + + reload(id, { + __hmrId: id, + setup() { + const count = ref(2) + return { count } + }, + render: compileToFunction(`
{{ count }}
`), + }) + await timeout() + expect(serializeInner(root)).toBe('
2
') + }) }) diff --git a/packages/runtime-core/src/components/BaseTransition.ts b/packages/runtime-core/src/components/BaseTransition.ts index 2b58bc3fc..03552a2b7 100644 --- a/packages/runtime-core/src/components/BaseTransition.ts +++ b/packages/runtime-core/src/components/BaseTransition.ts @@ -204,7 +204,7 @@ const BaseTransitionImpl: ComponentOptions = { if ( oldInnerChild && oldInnerChild.type !== Comment && - !isSameVNodeType(innerChild, oldInnerChild) && + !isSameVNodeType(oldInnerChild, innerChild) && recursiveGetSubtree(instance).type !== Comment ) { let leavingHooks = resolveTransitionHooks(