From 9c2de6244cd44bc5fbfd82b5850c710ce725044f Mon Sep 17 00:00:00 2001 From: edison Date: Mon, 29 Apr 2024 11:47:40 +0800 Subject: [PATCH] fix(runtime-core): ensure slot compiler marker writable (#10825) close #10818 --- packages/runtime-core/src/componentSlots.ts | 2 +- packages/shared/src/general.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/componentSlots.ts b/packages/runtime-core/src/componentSlots.ts index aeba4d5c6b0..2bc3466c459 100644 --- a/packages/runtime-core/src/componentSlots.ts +++ b/packages/runtime-core/src/componentSlots.ts @@ -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) } diff --git a/packages/shared/src/general.ts b/packages/shared/src/general.ts index 47ab0229255..fb884695d33 100644 --- a/packages/shared/src/general.ts +++ b/packages/shared/src/general.ts @@ -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, }) }