Przeglądaj źródła

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

close #10818
edison 2 lat temu
rodzic
commit
9c2de6244c

+ 1 - 1
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)
     }

+ 7 - 1
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,
   })
 }