Просмотр исходного кода

wip: v-skip work with v-if/v-else/v-else-if

daiwei 1 год назад
Родитель
Сommit
80c1e5c323
2 измененных файлов с 7 добавлено и 3 удалено
  1. 1 1
      packages/compiler-core/src/ast.ts
  2. 6 2
      packages/compiler-core/src/utils.ts

+ 1 - 1
packages/compiler-core/src/ast.ts

@@ -556,7 +556,7 @@ export interface DynamicSlotFnProperty extends Property {
 export type BlockCodegenNode = VNodeCall | RenderSlotCall
 export type BlockCodegenNode = VNodeCall | RenderSlotCall
 
 
 export interface IfConditionalExpression extends ConditionalExpression {
 export interface IfConditionalExpression extends ConditionalExpression {
-  consequent: BlockCodegenNode | MemoExpression
+  consequent: BlockCodegenNode | MemoExpression | ConditionalExpression
   alternate: BlockCodegenNode | IfConditionalExpression | MemoExpression
   alternate: BlockCodegenNode | IfConditionalExpression | MemoExpression
 }
 }
 
 

+ 6 - 2
packages/compiler-core/src/utils.ts

@@ -397,7 +397,11 @@ export function injectProp(
    * we need to get the real props before normalization
    * we need to get the real props before normalization
    */
    */
   let props =
   let props =
-    node.type === NodeTypes.VNODE_CALL ? node.props : node.arguments[2]
+    node.type === NodeTypes.VNODE_CALL
+      ? node.props
+      : node.type === NodeTypes.JS_CALL_EXPRESSION
+        ? node.arguments[2]
+        : undefined
   let callPath: CallExpression[] = []
   let callPath: CallExpression[] = []
   let parentCall: CallExpression | undefined
   let parentCall: CallExpression | undefined
   if (
   if (
@@ -459,7 +463,7 @@ export function injectProp(
     } else {
     } else {
       node.props = propsWithInjection
       node.props = propsWithInjection
     }
     }
-  } else {
+  } else if (node.type === NodeTypes.JS_CALL_EXPRESSION) {
     if (parentCall) {
     if (parentCall) {
       parentCall.arguments[0] = propsWithInjection
       parentCall.arguments[0] = propsWithInjection
     } else {
     } else {