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 {
6060 // option in the DOM.
6161 const needReset = el . multiple
6262 ? 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 )
6464 if ( needReset ) {
6565 trigger ( el , 'change' )
6666 }
Original file line number Diff line number Diff line change @@ -161,6 +161,32 @@ describe('Directive v-model select', () => {
161161 } ) . then ( done )
162162 } )
163163
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+
164190 it ( 'multiple' , done => {
165191 const vm = new Vue ( {
166192 data : {
You can’t perform that action at this time.
0 commit comments