]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: avoid proxy when slots are static
authorEvan You <evan@vuejs.org>
Fri, 6 Dec 2024 15:10:41 +0000 (23:10 +0800)
committerEvan You <evan@vuejs.org>
Fri, 6 Dec 2024 15:11:30 +0000 (23:11 +0800)
packages/runtime-vapor/src/component.ts
packages/runtime-vapor/src/componentSlots.ts

index 79f05c9cd68a51ab5747262e92f354219574a23d..bb2e21db0d56cc2e2521e8667549a703158a6167 100644 (file)
@@ -35,7 +35,7 @@ import { setClass, setDynamicProp } from './dom/prop'
 import {
   type RawSlots,
   type StaticSlots,
-  slotsProxyHandlers,
+  dynamicSlotsProxyHandlers,
 } from './componentSlots'
 
 export { currentInstance } from '@vue/runtime-dom'
@@ -257,7 +257,11 @@ export class VaporComponentInstance implements GenericComponentInstance {
     }
 
     // init slots
-    this.slots = rawSlots ? new Proxy(rawSlots, slotsProxyHandlers) : EMPTY_OBJ
+    this.slots = rawSlots
+      ? rawSlots.$
+        ? new Proxy(rawSlots, dynamicSlotsProxyHandlers)
+        : rawSlots
+      : EMPTY_OBJ
 
     if (__DEV__) {
       // validate props
index a77ade4f3ce1eec9b90dafe43efe664ae930d2e6..3a37abee2495a3ee2b5aa2de072daaa8275922d3 100644 (file)
@@ -11,7 +11,7 @@ export type Slot = (...args: any[]) => Block
 export type DynamicSlot = { name: string; fn: Slot }
 export type DynamicSlotFn = () => DynamicSlot | DynamicSlot[]
 
-export const slotsProxyHandlers: ProxyHandler<RawSlots> = {
+export const dynamicSlotsProxyHandlers: ProxyHandler<RawSlots> = {
   get: getSlot,
   has: (target, key: string) => !!getSlot(target, key),
   getOwnPropertyDescriptor(target, key: string) {