Explorar el Código

Revert "chore: cache buildSlots result"

This reverts commit 7327a573fe27525f5dfe93bf8686324f4be7c0a5.
daiwei hace 1 año
padre
commit
74e8bb44cb

+ 0 - 2
packages/compiler-core/src/ast.ts

@@ -153,8 +153,6 @@ export interface PlainElementNode extends BaseElementNode {
 
 export interface ComponentNode extends BaseElementNode {
   tagType: ElementTypes.COMPONENT
-  slots: SlotsExpression
-  hasDynamicSlots: boolean
   codegenNode:
     | VNodeCall
     | CacheExpression // when cached by v-once

+ 1 - 4
packages/compiler-core/src/transforms/transformElement.ts

@@ -173,10 +173,7 @@ export const transformElement: NodeTransform = (node, context) => {
         vnodeTag !== KEEP_ALIVE
 
       if (shouldBuildAsSlots) {
-        const { slots, hasDynamicSlots } = buildSlots(
-          node as ComponentNode,
-          context,
-        )
+        const { slots, hasDynamicSlots } = buildSlots(node, context)
         vnodeChildren = slots
         if (hasDynamicSlots) {
           patchFlag |= PatchFlags.DYNAMIC_SLOTS

+ 4 - 2
packages/compiler-core/src/transforms/vSkip.ts

@@ -6,6 +6,7 @@ import {
   NodeTypes,
   type SimpleExpressionNode,
   type SkipNode,
+  type SlotsExpression,
   type TemplateChildNode,
   createConditionalExpression,
   createSimpleExpression,
@@ -78,8 +79,9 @@ export function processSkip(
   // if not found, throw an error
   if (node.tagType === ElementTypes.COMPONENT) {
     const { slots } = buildSlots(node, context)
-    if (slots.type === NodeTypes.JS_OBJECT_EXPRESSION) {
-      const prop = slots.properties.find(
+    const genChildren = slots as SlotsExpression
+    if (genChildren.type === NodeTypes.JS_OBJECT_EXPRESSION) {
+      const prop = genChildren.properties.find(
         p =>
           p.type === NodeTypes.JS_PROPERTY &&
           p.key.type === NodeTypes.SIMPLE_EXPRESSION &&

+ 2 - 11
packages/compiler-core/src/transforms/vSlot.ts

@@ -1,8 +1,8 @@
 import {
   type CallExpression,
-  type ComponentNode,
   type ConditionalExpression,
   type DirectiveNode,
+  type ElementNode,
   ElementTypes,
   type ExpressionNode,
   type FunctionExpression,
@@ -114,20 +114,13 @@ const buildClientSlotFn: SlotFnBuilder = (props, _vForExp, children, loc) =>
 // Instead of being a DirectiveTransform, v-slot processing is called during
 // transformElement to build the slots object for a component.
 export function buildSlots(
-  node: ComponentNode,
+  node: ElementNode,
   context: TransformContext,
   buildSlotFn: SlotFnBuilder = buildClientSlotFn,
 ): {
   slots: SlotsExpression
   hasDynamicSlots: boolean
 } {
-  // return early if slots are already built to avoid duplication
-  if (node.slots) {
-    return {
-      slots: node.slots,
-      hasDynamicSlots: node.hasDynamicSlots,
-    }
-  }
   context.helper(WITH_CTX)
 
   const { children, loc } = node
@@ -371,8 +364,6 @@ export function buildSlots(
     ]) as SlotsExpression
   }
 
-  node.slots = slots
-  node.hasDynamicSlots = hasDynamicSlots
   return {
     slots,
     hasDynamicSlots,