fix(runtime-core): delete stale slots which are present but undefined (#6484)

close #9109
This commit is contained in:
Kael 2023-10-20 19:25:06 +11:00 committed by GitHub
parent 61c1357427
commit 75b8722135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -134,9 +134,11 @@ describe('component: slots', () => {
} }
const oldSlots = { const oldSlots = {
header: 'header' header: 'header',
footer: undefined
} }
const newSlots = { const newSlots = {
header: undefined,
footer: 'footer' footer: 'footer'
} }

View File

@ -234,7 +234,7 @@ export const updateSlots = (
// delete stale slots // delete stale slots
if (needDeletionCheck) { if (needDeletionCheck) {
for (const key in slots) { for (const key in slots) {
if (!isInternalKey(key) && !(key in deletionComparisonTarget)) { if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
delete slots[key] delete slots[key]
} }
} }