]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): delete stale slots which are present but undefined (#6484)
authorKael <kaelwd@gmail.com>
Fri, 20 Oct 2023 08:25:06 +0000 (19:25 +1100)
committerGitHub <noreply@github.com>
Fri, 20 Oct 2023 08:25:06 +0000 (16:25 +0800)
close #9109

packages/runtime-core/__tests__/componentSlots.spec.ts
packages/runtime-core/src/componentSlots.ts

index f08f1910cd42d66a2be4da6e8c6b2d826ce5437a..708fb20c423c048f396be8c19e2a2733bb197194 100644 (file)
@@ -134,9 +134,11 @@ describe('component: slots', () => {
     }
 
     const oldSlots = {
-      header: 'header'
+      header: 'header',
+      footer: undefined
     }
     const newSlots = {
+      header: undefined,
       footer: 'footer'
     }
 
index afc5f03933be39c43c7f242227ed7cc14f4a4e06..980ee799186f8531df642a64d77ad28080681a10 100644 (file)
@@ -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]
       }
     }