File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
src/platforms/web/runtime/directives
test/unit/features/directives Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ export default {
60
60
// option in the DOM.
61
61
const needReset = el . multiple
62
62
? binding . value . some ( v => hasNoMatchingOption ( v , el . options ) )
63
- : hasNoMatchingOption ( binding . value , el . options )
63
+ : binding . value === binding . oldValue ? false : hasNoMatchingOption ( binding . value , el . options )
64
64
if ( needReset ) {
65
65
trigger ( el , 'change' )
66
66
}
Original file line number Diff line number Diff line change @@ -161,6 +161,32 @@ describe('Directive v-model select', () => {
161
161
} ) . then ( done )
162
162
} )
163
163
164
+ it ( 'should work with select which has no default selected options' , ( done ) => {
165
+ const spy = jasmine . createSpy ( )
166
+ const vm = new Vue ( {
167
+ data : {
168
+ id : 4 ,
169
+ list : [ 1 , 2 , 3 ] ,
170
+ testChange : 5
171
+ } ,
172
+ template :
173
+ '<div>' +
174
+ '<select @change="test" v-model="id">' +
175
+ '<option v-for="item in list" :value="item">{{item}}</option>' +
176
+ '</select>' +
177
+ '{{testChange}}' +
178
+ '</div>' ,
179
+ methods : {
180
+ test : spy
181
+ }
182
+ } ) . $mount ( )
183
+ document . body . appendChild ( vm . $el )
184
+ vm . testChange = 10
185
+ waitForUpdate ( ( ) => {
186
+ expect ( spy . calls . count ( ) ) . toBe ( 0 )
187
+ } ) . then ( done )
188
+ } )
189
+
164
190
it ( 'multiple' , done => {
165
191
const vm = new Vue ( {
166
192
data : {
You can’t perform that action at this time.
0 commit comments