Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/platforms/web/runtime/directives/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default {
// option in the DOM.
const needReset = el.multiple
? binding.value.some(v => hasNoMatchingOption(v, el.options))
: hasNoMatchingOption(binding.value, el.options)
: binding.value === binding.oldValue ? false : hasNoMatchingOption(binding.value, el.options)
if (needReset) {
trigger(el, 'change')
}
Expand Down
26 changes: 26 additions & 0 deletions test/unit/features/directives/model-select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,32 @@ describe('Directive v-model select', () => {
}).then(done)
})

it('should work with select which has no default selected options', (done) => {
const spy = jasmine.createSpy()
const vm = new Vue({
data: {
id: 4,
list: [1, 2, 3],
testChange: 5
},
template:
'<div>' +
'<select @change="test" v-model="id">' +
'<option v-for="item in list" :value="item">{{item}}</option>' +
'</select>' +
'{{testChange}}' +
'</div>',
methods: {
test: spy
}
}).$mount()
document.body.appendChild(vm.$el)
vm.testChange = 10
waitForUpdate(() => {
expect(spy.calls.count()).toBe(0)
}).then(done)
})

it('multiple', done => {
const vm = new Vue({
data: {
Expand Down