From e3ef24faacf464ea354a052f84714d88a555c3dc Mon Sep 17 00:00:00 2001 From: Kael Date: Fri, 20 Oct 2023 19:25:06 +1100 Subject: [PATCH] fix(runtime-core): delete stale slots which are present but undefined (#6484) close #9109 --- packages/runtime-core/__tests__/componentSlots.spec.ts | 4 +++- packages/runtime-core/src/componentSlots.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/__tests__/componentSlots.spec.ts b/packages/runtime-core/__tests__/componentSlots.spec.ts index f08f1910cd4..708fb20c423 100644 --- a/packages/runtime-core/__tests__/componentSlots.spec.ts +++ b/packages/runtime-core/__tests__/componentSlots.spec.ts @@ -134,9 +134,11 @@ describe('component: slots', () => { } const oldSlots = { - header: 'header' + header: 'header', + footer: undefined } const newSlots = { + header: undefined, footer: 'footer' } diff --git a/packages/runtime-core/src/componentSlots.ts b/packages/runtime-core/src/componentSlots.ts index afc5f03933b..980ee799186 100644 --- a/packages/runtime-core/src/componentSlots.ts +++ b/packages/runtime-core/src/componentSlots.ts @@ -234,7 +234,7 @@ export const updateSlots = ( // delete stale slots if (needDeletionCheck) { for (const key in slots) { - if (!isInternalKey(key) && !(key in deletionComparisonTarget)) { + if (!isInternalKey(key) && deletionComparisonTarget[key] == null) { delete slots[key] } }