fix(runtime-core): ensure slot compiler marker writable (#10825)

close #10818
This commit is contained in:
edison 2024-04-29 11:47:40 +08:00 committed by GitHub
parent 47453f102e
commit 9c2de6244c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -171,7 +171,7 @@ export const initSlots = (
if (type) {
extend(slots, children as InternalSlots)
// make compiler marker non-enumerable
def(slots, '_', type)
def(slots, '_', type, true)
} else {
normalizeObjectSlots(children as RawSlots, slots, instance)
}

View File

@ -139,10 +139,16 @@ 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,
writable = false,
) => {
Object.defineProperty(obj, key, {
configurable: true,
enumerable: false,
writable,
value,
})
}