]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(slots): make compiled slot marker non-enumerable
authorEvan You <yyx990803@gmail.com>
Tue, 30 Jun 2020 13:26:25 +0000 (09:26 -0400)
committerEvan You <yyx990803@gmail.com>
Tue, 30 Jun 2020 13:27:06 +0000 (09:27 -0400)
fix #1470

packages/runtime-core/src/componentSlots.ts
packages/shared/src/index.ts

index 7cba0eb13bb9f43b12d8eb77f8e5d2826e22164b..a940fd5f7bddffcc2075078664feef87fda56783 100644 (file)
@@ -102,10 +102,9 @@ export const initSlots = (
 ) => {
   if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
     if ((children as RawSlots)._ === 1) {
-      const slots: InternalSlots = (instance.slots = {})
-      for (const key in children as RawSlots) {
-        if (key !== '_') slots[key] = (children as Slots)[key]
-      }
+      instance.slots = children as InternalSlots
+      // make compiler marker non-enumerable
+      def(children as InternalSlots, '_', 1)
     } else {
       normalizeObjectSlots(children as RawSlots, (instance.slots = {}))
     }
index d844487f0b5417a6fc7bb68fdaf42ad528a88709..9aa9ad9a34832b60ad5e61cf70581f149217626c 100644 (file)
@@ -114,6 +114,7 @@ export const invokeArrayFns = (fns: Function[], arg?: any) => {
 export const def = (obj: object, key: string | symbol, value: any) => {
   Object.defineProperty(obj, key, {
     configurable: true,
+    enumerable: false,
     value
   })
 }