From: Evan You Date: Fri, 26 Jun 2020 21:18:39 +0000 (-0400) Subject: fix(slots): filter out compiler marker from resolved slots X-Git-Tag: v3.0.0-beta.16~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70ea76ae0c16a55154e785f8ca42ed13e0d15170;p=thirdparty%2Fvuejs%2Fcore.git fix(slots): filter out compiler marker from resolved slots fix #1451 --- diff --git a/packages/runtime-core/src/componentSlots.ts b/packages/runtime-core/src/componentSlots.ts index e819ab64f9..7cba0eb13b 100644 --- a/packages/runtime-core/src/componentSlots.ts +++ b/packages/runtime-core/src/componentSlots.ts @@ -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)