]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: adjust slot props compilation
authorEvan You <evan@vuejs.org>
Sun, 8 Dec 2024 03:02:11 +0000 (11:02 +0800)
committerEvan You <evan@vuejs.org>
Sun, 8 Dec 2024 03:02:11 +0000 (11:02 +0800)
packages/compiler-vapor/src/generators/component.ts

index 4ab96d3b6ec6a4e21f08bb44178def3b232b7a05..8f540730445be1884bc9fd4405816736babe6372 100644 (file)
@@ -342,7 +342,7 @@ function genSlotBlockWithProps(oper: SlotBlockIRNode, context: CodegenContext) {
     rawProps = props.content
     if ((isDestructureAssignment = !!props.ast)) {
       ;[depth, exitScope] = context.enterScope()
-      propsName = `_ctx${depth}`
+      propsName = `_slotProps${depth}`
       walkIdentifiers(
         props.ast,
         (id, _, __, ___, isLocal) => {
@@ -357,26 +357,17 @@ function genSlotBlockWithProps(oper: SlotBlockIRNode, context: CodegenContext) {
 
   const idMap: Record<string, string | null> = {}
 
-  Array.from(idsOfProps).forEach(
-    (id, idIndex) =>
-      (idMap[id] = isDestructureAssignment ? `${propsName}[${idIndex}]` : null),
+  idsOfProps.forEach(
+    id =>
+      (idMap[id] = isDestructureAssignment
+        ? `${propsName}[${JSON.stringify(id)}]`
+        : null),
   )
-  let blockFn = context.withId(
+  const blockFn = context.withId(
     () => genBlock(oper, context, [propsName]),
     idMap,
   )
   exitScope && exitScope()
 
-  if (isDestructureAssignment) {
-    const idMap: Record<string, null> = {}
-    idsOfProps.forEach(id => (idMap[id] = null))
-
-    blockFn = genCall(
-      context.vaporHelper('withDestructure'),
-      ['(', rawProps, ') => ', ...genMulti(DELIMITERS_ARRAY, ...idsOfProps)],
-      blockFn,
-    )
-  }
-
   return blockFn
 }