diff --git a/packages/compiler-core/__tests__/transforms/vModel.spec.ts b/packages/compiler-core/__tests__/transforms/vModel.spec.ts index 96dbe2cb5fb..0af7d9eb608 100644 --- a/packages/compiler-core/__tests__/transforms/vModel.spec.ts +++ b/packages/compiler-core/__tests__/transforms/vModel.spec.ts @@ -10,7 +10,8 @@ import { ComponentNode, NodeTypes, VNodeCall, - NORMALIZE_PROPS + NORMALIZE_PROPS, + BindingTypes } from '../../src' import { ErrorCodes } from '../../src/errors' import { transformModel } from '../../src/transforms/vModel' @@ -561,5 +562,22 @@ describe('compiler: transform v-model', () => { }) ) }) + + test('used on props', () => { + const onError = jest.fn() + parseWithVModel('
', { + onError, + bindingMetadata: { + p: BindingTypes.PROPS + } + }) + + expect(onError).toHaveBeenCalledTimes(1) + expect(onError).toHaveBeenCalledWith( + expect.objectContaining({ + code: ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE + }) + ) + }) }) }) diff --git a/packages/compiler-core/src/errors.ts b/packages/compiler-core/src/errors.ts index f0af09dda31..345aa183fc9 100644 --- a/packages/compiler-core/src/errors.ts +++ b/packages/compiler-core/src/errors.ts @@ -87,6 +87,7 @@ export const enum ErrorCodes { X_V_MODEL_NO_EXPRESSION, X_V_MODEL_MALFORMED_EXPRESSION, X_V_MODEL_ON_SCOPE_VARIABLE, + X_V_MODEL_ON_PROPS, X_INVALID_EXPRESSION, X_KEEP_ALIVE_INVALID_CHILDREN, @@ -168,6 +169,7 @@ export const errorMessages: Record