diff --git a/src/directives/model/select.js b/src/directives/model/select.js
index 7cb3d9a244d..4a4a4316bae 100644
--- a/src/directives/model/select.js
+++ b/src/directives/model/select.js
@@ -103,6 +103,7 @@ function initOptions (expression) {
parentNode.removeChild(option)
} else {
el.removeChild(parentNode)
+ i = el.options.length
}
}
}
diff --git a/test/unit/specs/directives/model_spec.js b/test/unit/specs/directives/model_spec.js
index 1661e00d273..d80d6d849ce 100644
--- a/test/unit/specs/directives/model_spec.js
+++ b/test/unit/specs/directives/model_spec.js
@@ -373,10 +373,10 @@ if (_.inBrowser) {
_.nextTick(function () {
expect(el.firstChild.innerHTML).toBe(
'' +
''
)
var opts = el.firstChild.options
@@ -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: ''
+ })
+ 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,