Skip to content

Commit 062835d

Browse files
committed
fix(slots): make compiled slot marker non-enumerable
fix #1470
1 parent 3a7690e commit 062835d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/runtime-core/src/componentSlots.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,9 @@ export const initSlots = (
102102
) => {
103103
if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
104104
if ((children as RawSlots)._ === 1) {
105-
const slots: InternalSlots = (instance.slots = {})
106-
for (const key in children as RawSlots) {
107-
if (key !== '_') slots[key] = (children as Slots)[key]
108-
}
105+
instance.slots = children as InternalSlots
106+
// make compiler marker non-enumerable
107+
def(children as InternalSlots, '_', 1)
109108
} else {
110109
normalizeObjectSlots(children as RawSlots, (instance.slots = {}))
111110
}

packages/shared/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export const invokeArrayFns = (fns: Function[], arg?: any) => {
114114
export const def = (obj: object, key: string | symbol, value: any) => {
115115
Object.defineProperty(obj, key, {
116116
configurable: true,
117+
enumerable: false,
117118
value
118119
})
119120
}

0 commit comments

Comments
 (0)