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
1 change: 1 addition & 0 deletions src/directives/model/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function initOptions (expression) {
parentNode.removeChild(option)
} else {
el.removeChild(parentNode)
i = el.options.length
}
}
}
Expand Down
31 changes: 29 additions & 2 deletions test/unit/specs/directives/model_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ if (_.inBrowser) {
_.nextTick(function () {
expect(el.firstChild.innerHTML).toBe(
'<optgroup label="X">' +
'<option value="x">x</option><option value="y">y</option>' +
'<option value="x">x</option><option value="y">y</option>' +
'</optgroup>' +
'<optgroup label="Y">' +
'<option value="z">z</option>' +
'<option value="z">z</option>' +
'</optgroup>'
)
var opts = el.firstChild.options
Expand All @@ -387,6 +387,33 @@ if (_.inBrowser) {
})
})

it('select + options + optgroup + default option', function (done) {
var vm = new Vue({
el: el,
data: {
test: '',
opts: [
{ label: 'A', options: ['a', 'b'] },
{ label: 'B', options: ['c'] }
]
},
template: '<select v-model="test" options="opts"><option value=""></option></select>'
})
var opts = el.firstChild.options
expect(opts[0].selected).toBe(true)
expect(el.firstChild.value).toBe('')
vm.opts = [
{ label: 'X', options: ['x', 'y'] },
{ label: 'Y', options: ['z'] }
]
_.nextTick(function () {
var opts = el.firstChild.options
expect(opts[0].selected).toBe(true)
expect(el.firstChild.value).toBe('')
done()
})
})

it('select + options with Object value', function (done) {
var vm = new Vue({
el: el,
Expand Down