From: daiwei Date: Wed, 15 Jan 2025 05:57:18 +0000 (+0800) Subject: test: add test case X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1373bc7c05ee5db799a0da20819304f5398d743c;p=thirdparty%2Fvuejs%2Fcore.git test: add test case --- diff --git a/packages/runtime-core/__tests__/helpers/withMemo.spec.ts b/packages/runtime-core/__tests__/helpers/withMemo.spec.ts index 32f89b1d8e..cc447327e3 100644 --- a/packages/runtime-core/__tests__/helpers/withMemo.spec.ts +++ b/packages/runtime-core/__tests__/helpers/withMemo.spec.ts @@ -204,6 +204,32 @@ describe('v-memo', () => { ) }) + // #12708 + test('v-memo should work correctly when toggling v-if with v-for inside', async () => { + const [el, vm] = mount({ + template: ` + {{count}} + `, + data: () => ({ + show: true, + count: 0, + }), + }) + expect(el.innerHTML).toBe(`0`) + + vm.show = false + await nextTick() + expect(el.innerHTML).toBe(``) + + vm.show = true + await nextTick() + expect(el.innerHTML).toBe(`0`) + + vm.count++ + await nextTick() + expect(el.innerHTML).toBe(`1`) + }) + test('on v-for /w constant expression ', async () => { const [el, vm] = mount({ template: `
diff --git a/packages/runtime-core/src/vnode.ts b/packages/runtime-core/src/vnode.ts index 97a9e8b234..34aea8f79c 100644 --- a/packages/runtime-core/src/vnode.ts +++ b/packages/runtime-core/src/vnode.ts @@ -243,7 +243,7 @@ export interface VNode< memo?: any[] /** * @internal index for cleaning v-memo cache - * cacheIndex will be an array when vnode in vFor + * cacheIndex will be an array when vnode in vFor + vMemo */ cacheIndex?: number | number[] /**