From: Evan You Date: Tue, 30 Jun 2020 13:26:25 +0000 (-0400) Subject: fix(slots): make compiled slot marker non-enumerable X-Git-Tag: v3.0.0-beta.17~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=062835d45aaf4168ddf2e39a5c7e162b3a18ccae;p=thirdparty%2Fvuejs%2Fcore.git fix(slots): make compiled slot marker non-enumerable fix #1470 --- diff --git a/packages/runtime-core/src/componentSlots.ts b/packages/runtime-core/src/componentSlots.ts index 7cba0eb13b..a940fd5f7b 100644 --- a/packages/runtime-core/src/componentSlots.ts +++ b/packages/runtime-core/src/componentSlots.ts @@ -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 = {})) } diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index d844487f0b..9aa9ad9a34 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -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 }) }