diff --git a/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap b/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap index 8c9d875c4..fd2bfd2f8 100644 --- a/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap +++ b/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap @@ -3925,6 +3925,7 @@ exports[`compiler: parse > Errors > X_COLON_BEFORE_DIRECTIVE >
Errors > X_COLON_BEFORE_DIRECTIVE >
", "temps": 0, "type": 0, } diff --git a/packages/compiler-core/src/parser.ts b/packages/compiler-core/src/parser.ts index e73bffdeb..0750a1858 100644 --- a/packages/compiler-core/src/parser.ts +++ b/packages/compiler-core/src/parser.ts @@ -256,6 +256,17 @@ const tokenizer = new Tokenizer(stack, { getLoc(start, end), isStatic ? ConstantTypes.CAN_STRINGIFY : ConstantTypes.NOT_CONSTANT, ) + if ( + __DEV__ && + arg.startsWith('v-') && + (currentProp as DirectiveNode).rawName === ':' + ) { + emitWarning( + ErrorCodes.X_COLON_BEFORE_DIRECTIVE, + start - 1, + `the attribute name :${arg} is probably a mistake. Did you mean ${arg} instead?`, + ) + } } }, @@ -1007,6 +1018,12 @@ function emitError(code: ErrorCodes, index: number, message?: string) { ) } +function emitWarning(code: ErrorCodes, index: number, message?: string) { + currentOptions.onWarn( + createCompilerError(code, getLoc(index, index), undefined, message), + ) +} + function reset() { tokenizer.reset() currentOpenTag = null