feat(compiler-core/v-model): error when v-model is used on scope variable
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
createInterpolation
|
||||
} from '../ast'
|
||||
import { createCompilerError, ErrorCodes } from '../errors'
|
||||
import { isMemberExpression } from '../utils'
|
||||
import { isMemberExpression, isSimpleIdentifier } from '../utils'
|
||||
import { isObject } from '@vue/shared'
|
||||
|
||||
export const transformModel: DirectiveTransform = (dir, node, context) => {
|
||||
@@ -30,6 +30,18 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
|
||||
return createTransformProps()
|
||||
}
|
||||
|
||||
if (
|
||||
!__BROWSER__ &&
|
||||
context.prefixIdentifiers &&
|
||||
isSimpleIdentifier(expString) &&
|
||||
context.identifiers[expString]
|
||||
) {
|
||||
context.onError(
|
||||
createCompilerError(ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE, exp.loc)
|
||||
)
|
||||
return createTransformProps()
|
||||
}
|
||||
|
||||
const propName = arg ? arg : createSimpleExpression('modelValue', true)
|
||||
const eventName = arg
|
||||
? arg.type === NodeTypes.SIMPLE_EXPRESSION && arg.isStatic
|
||||
|
||||
Reference in New Issue
Block a user