Skip to content

Commit 9041f2f

Browse files
committed
Merge pull request #766 from nazo/dev
fix <option value="" selected> is undefined
2 parents 9252b6e + 0f4bfb0 commit 9041f2f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/directives/model/select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function checkInitialValue () {
134134
}
135135
}
136136
}
137-
if (initValue) {
137+
if (typeof initValue !== 'undefined') {
138138
this._initValue = this.number
139139
? _.toNumber(initValue)
140140
: initValue

test/unit/specs/directives/model_spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ if (_.inBrowser) {
156156
expect(el.firstChild.childNodes[1].selected).toBe(true)
157157
})
158158

159+
it('select + empty default value', function () {
160+
var vm = new Vue({
161+
el: el,
162+
template: '<select v-model="test"><option value="" selected>null</option><<option value="1">1</option></select>'
163+
})
164+
expect(vm.test).toBe('')
165+
trigger(vm.$el.firstChild, 'change')
166+
expect(vm.test).toBe('')
167+
})
168+
159169
it('select + multiple', function (done) {
160170
var vm = new Vue({
161171
el: el,

0 commit comments

Comments
 (0)