]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(slots): filter out compiler marker from resolved slots
authorEvan You <yyx990803@gmail.com>
Fri, 26 Jun 2020 21:18:39 +0000 (17:18 -0400)
committerEvan You <yyx990803@gmail.com>
Fri, 26 Jun 2020 21:18:39 +0000 (17:18 -0400)
fix #1451

packages/runtime-core/src/componentSlots.ts

index e819ab64f90fc7d803d86e4eb958d181d10c7b01..7cba0eb13bb9f43b12d8eb77f8e5d2826e22164b 100644 (file)
@@ -102,7 +102,10 @@ export const initSlots = (
 ) => {
   if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
     if ((children as RawSlots)._ === 1) {
-      instance.slots = children as InternalSlots
+      const slots: InternalSlots = (instance.slots = {})
+      for (const key in children as RawSlots) {
+        if (key !== '_') slots[key] = (children as Slots)[key]
+      }
     } else {
       normalizeObjectSlots(children as RawSlots, (instance.slots = {}))
     }
@@ -128,7 +131,9 @@ export const updateSlots = (
       if (__DEV__ && isHmrUpdating) {
         // Parent was HMR updated so slot content may have changed.
         // force update slots and mark instance for hmr as well
-        extend(slots, children as Slots)
+        for (const key in children as RawSlots) {
+          if (key !== '_') slots[key] = (children as Slots)[key]
+        }
       } else if (
         // bail on dynamic slots (v-if, v-for, reference of scope variables)
         !(vnode.patchFlag & PatchFlags.DYNAMIC_SLOTS)