Skip to content

Commit b9def18

Browse files
committed
feat(RFC0005): allow v-model argument when v-model is used on custom component
1 parent fe190dc commit b9def18

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

docs/rules/valid-v-model.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This rule checks whether every `v-model` directive is valid.
1515

1616
This rule reports `v-model` directives in the following cases:
1717

18-
- The directive has that argument. E.g. `<input v-model:aaa="foo">`
18+
- The directive used on HTMLElement has an argument. E.g. `<input v-model:aaa="foo">`
1919
- The directive has the modifiers which are not supported. E.g. `<input v-model.bbb="foo">`
2020
- The directive does not have that attribute value. E.g. `<input v-model>`
2121
- The directive does not have the attribute value which is valid as LHS. E.g. `<input v-model="foo() + bar()">`
@@ -32,6 +32,7 @@ This rule reports `v-model` directives in the following cases:
3232
<input v-model.lazy="foo">
3333
<textarea v-model="foo"/>
3434
<MyComponent v-model="foo"/>
35+
<MyComponent v-model:propName="foo"/>
3536
<div v-for="todo in todos">
3637
<input v-model="todo.name">
3738
</div>

lib/rules/valid-v-model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ module.exports = {
112112
})
113113
}
114114

115-
if (node.key.argument) {
115+
if (node.key.argument && !utils.isCustomComponent(element)) {
116116
context.report({
117117
node,
118118
loc: node.loc,

tests/lib/rules/valid-v-model.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ tester.run('valid-v-model', rule, {
114114
{
115115
filename: 'test.vue',
116116
code: '<template><input v-bind:type="a" v-model="b"></template>'
117+
},
118+
{
119+
filename: 'test.vue',
120+
code: '<template><MyComponent v-model:aaa="a"></MyComponent></template>'
117121
}
118122
],
119123
invalid: [

0 commit comments

Comments
 (0)