feat(compiler-core/v-model): error when v-model is used on scope variable

This commit is contained in:
Evan You
2019-10-16 14:05:18 -04:00
parent 5481f76ce8
commit 25dd507f71
4 changed files with 39 additions and 5 deletions

View File

@@ -361,7 +361,7 @@ describe('compiler: transform v-model', () => {
test('should mark update handler dynamic if it refers slot scope variables', () => {
const root = parseWithVModel(
'<Comp v-slot="{ foo }"><input v-model="foo"/></Comp>',
'<Comp v-slot="{ foo }"><input v-model="foo.bar"/></Comp>',
{
prefixIdentifiers: true
}
@@ -407,5 +407,20 @@ describe('compiler: transform v-model', () => {
})
)
})
test('used on scope variable', () => {
const onError = jest.fn()
parseWithVModel('<span v-for="i in list" v-model="i" />', {
onError,
prefixIdentifiers: true
})
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
code: ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE
})
)
})
})
})