From 2029617f6ba1f8a87b0a599b04a677aac129470e Mon Sep 17 00:00:00 2001 From: edison <daiwei521@126.com> 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 0900d996cda..47e7844851f 100644 --- a/packages/shared/src/general.ts +++ b/packages/shared/src/general.ts @@ -140,10 +140,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, }) }