fix(slots): make compiled slot marker non-enumerable

fix #1470
This commit is contained in:
Evan You 2020-06-30 09:26:25 -04:00
parent 3a7690ee98
commit 062835d45a
2 changed files with 4 additions and 4 deletions

View File

@ -102,10 +102,9 @@ export const initSlots = (
) => { ) => {
if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) { if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
if ((children as RawSlots)._ === 1) { if ((children as RawSlots)._ === 1) {
const slots: InternalSlots = (instance.slots = {}) instance.slots = children as InternalSlots
for (const key in children as RawSlots) { // make compiler marker non-enumerable
if (key !== '_') slots[key] = (children as Slots)[key] def(children as InternalSlots, '_', 1)
}
} else { } else {
normalizeObjectSlots(children as RawSlots, (instance.slots = {})) normalizeObjectSlots(children as RawSlots, (instance.slots = {}))
} }

View File

@ -114,6 +114,7 @@ export const invokeArrayFns = (fns: Function[], arg?: any) => {
export const def = (obj: object, key: string | symbol, value: any) => { export const def = (obj: object, key: string | symbol, value: any) => {
Object.defineProperty(obj, key, { Object.defineProperty(obj, key, {
configurable: true, configurable: true,
enumerable: false,
value value
}) })
} }