]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: warn work with v-for
authordaiwei <daiwei521@126.com>
Thu, 23 Jan 2025 00:36:47 +0000 (08:36 +0800)
committerdaiwei <daiwei521@126.com>
Thu, 23 Jan 2025 00:36:47 +0000 (08:36 +0800)
packages/compiler-core/src/ast.ts
packages/compiler-core/src/errors.ts
packages/compiler-core/src/transforms/vSkip.ts

index a3c6bd96c031831f45eab510dfe56376fe648f4c..2956a4b3dc337aaad11e08f1303d8fd53948f3be 100644 (file)
@@ -556,7 +556,7 @@ export interface DynamicSlotFnProperty extends Property {
 export type BlockCodegenNode = VNodeCall | RenderSlotCall
 
 export interface IfConditionalExpression extends ConditionalExpression {
-  consequent: BlockCodegenNode | MemoExpression | ConditionalExpression
+  consequent: BlockCodegenNode | MemoExpression
   alternate: BlockCodegenNode | IfConditionalExpression | MemoExpression
 }
 
index b5b5e8cd3e3ba29755be8e7be166c61b4ffef5c9..048902be604eefcdf6fc1faae5ecb038250c534a 100644 (file)
@@ -93,6 +93,7 @@ export enum ErrorCodes {
   X_V_SKIP_NO_EXPRESSION,
   X_V_SKIP_ON_TEMPLATE,
   X_V_SKIP_UNEXPECTED_SLOT,
+  X_V_SKIP_WITH_V_FOR,
 
   // generic errors
   X_PREFIX_ID_NOT_SUPPORTED,
@@ -185,6 +186,7 @@ export const errorMessages: Record<ErrorCodes, string> = {
   [ErrorCodes.X_V_SKIP_NO_EXPRESSION]: `v-skip is missing expression.`,
   [ErrorCodes.X_V_SKIP_ON_TEMPLATE]: `v-skip cannot be used on <template> or <slot> tags.`,
   [ErrorCodes.X_V_SKIP_UNEXPECTED_SLOT]: `v-skip directive requires the component to have a default slot without slot props`,
+  [ErrorCodes.X_V_SKIP_WITH_V_FOR]: `v-skip with v-for is not supported.`,
 
   // generic errors
   [ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
index d1568ef6bee4ec652a1f1ff8d709a80a9750d201..2e5d7a42f0db646dcb31f422c444e597837f4cb7 100644 (file)
@@ -15,6 +15,7 @@ import {
 import {
   ErrorCodes,
   createCompilerError,
+  findDir,
   findProp,
   isSlotOutlet,
   isTemplateNode,
@@ -32,6 +33,10 @@ export const transformSkip: NodeTransform = createStructuralDirectiveTransform(
       return
     }
 
+    if (findDir(node, 'for')) {
+      context.onWarn(createCompilerError(ErrorCodes.X_V_SKIP_WITH_V_FOR, loc))
+    }
+
     if (!dir.exp || !(dir.exp as SimpleExpressionNode).content.trim()) {
       context.onError(
         createCompilerError(ErrorCodes.X_V_SKIP_NO_EXPRESSION, loc),