From: Kael Date: Fri, 20 Oct 2023 08:25:06 +0000 (+1100) Subject: fix(runtime-core): delete stale slots which are present but undefined (#6484) X-Git-Tag: v3.3.6~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=75b872213574cb37e2c9e8a15f65613f867ca9a6;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-core): delete stale slots which are present but undefined (#6484) close #9109 --- diff --git a/packages/runtime-core/__tests__/componentSlots.spec.ts b/packages/runtime-core/__tests__/componentSlots.spec.ts index f08f1910cd..708fb20c42 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 afc5f03933..980ee79918 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] } }