Skip to content

Commit 9942ace

Browse files
committed
only warn v-repeat on options when select has a v-model
1 parent bf8e371 commit 9942ace

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/directives/model/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ module.exports = {
5050
)
5151
return
5252
}
53+
el.__v_model = this
5354
handler.bind.call(this)
5455
this.update = handler.update
55-
this.unbind = handler.unbind
56+
this._unbind = handler.unbind
5657
},
5758

5859
/**
@@ -72,5 +73,10 @@ module.exports = {
7273
this.hasWrite = true
7374
}
7475
}
76+
},
77+
78+
unbind: function () {
79+
this.el.__v_model = null
80+
this._unbind && this._unbind()
7581
}
7682
}

src/directives/repeat.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ module.exports = {
2121
*/
2222

2323
bind: function () {
24+
25+
// some helpful tips...
26+
/* istanbul ignore if */
27+
if (
28+
process.env.NODE_ENV !== 'production' &&
29+
this.el.tagName === 'OPTION' &&
30+
this.el.parentNode && this.el.parentNode.__v_model
31+
) {
32+
_.warn(
33+
'Don\'t use v-repeat for v-model options; ' +
34+
'use the `options` param instead: ' +
35+
'http://vuejs.org/guide/forms.html#Dynamic_Select_Options'
36+
)
37+
}
38+
2439
// support for item in array syntax
2540
var inMatch = this.expression.match(/(.*) in (.*)/)
2641
if (inMatch) {
@@ -59,19 +74,6 @@ module.exports = {
5974

6075
// create cache object
6176
this.cache = Object.create(null)
62-
63-
// some helpful tips...
64-
/* istanbul ignore if */
65-
if (
66-
process.env.NODE_ENV !== 'production' &&
67-
this.el.tagName === 'OPTION'
68-
) {
69-
_.warn(
70-
'Don\'t use v-repeat for v-model options; ' +
71-
'use the `options` param instead: ' +
72-
'http://vuejs.org/guide/forms.html#Dynamic_Select_Options'
73-
)
74-
}
7577
},
7678

7779
/**

0 commit comments

Comments
 (0)