|
@ -4,9 +4,9 @@ import { looseEqual } from 'shared/util' |
|
|
// Android 4.4 Chrome 30 has the bug that a multi-select option cannot be
|
|
|
// Android 4.4 Chrome 30 has the bug that a multi-select option cannot be
|
|
|
// deselected by setting its "selected" prop via JavaScript.
|
|
|
// deselected by setting its "selected" prop via JavaScript.
|
|
|
function hasMultiSelectBug () { |
|
|
function hasMultiSelectBug () { |
|
|
var s = document.createElement('select') |
|
|
const s = document.createElement('select') |
|
|
s.setAttribute('multiple', '') |
|
|
s.setAttribute('multiple', '') |
|
|
var o = document.createElement('option') |
|
|
const o = document.createElement('option') |
|
|
s.appendChild(o) |
|
|
s.appendChild(o) |
|
|
o.selected = true |
|
|
o.selected = true |
|
|
o.selected = false |
|
|
o.selected = false |
|
@ -18,8 +18,8 @@ function hasMultiSelectBug () { |
|
|
* we have to manually loop through the options |
|
|
* we have to manually loop through the options |
|
|
*/ |
|
|
*/ |
|
|
function updateSelect (el, value) { |
|
|
function updateSelect (el, value) { |
|
|
var options = el.options |
|
|
const options = el.options |
|
|
var i = options.length |
|
|
let i = options.length |
|
|
while (i--) { |
|
|
while (i--) { |
|
|
if (looseEqual(getValue(options[i]), value)) { |
|
|
if (looseEqual(getValue(options[i]), value)) { |
|
|
options[i].selected = true |
|
|
options[i].selected = true |
|
@ -245,7 +245,7 @@ describe('Directive v-model select', () => { |
|
|
'<option>c</option>' + |
|
|
'<option>c</option>' + |
|
|
'</select>' |
|
|
'</select>' |
|
|
}).$mount() |
|
|
}).$mount() |
|
|
var opts = vm.$el.options |
|
|
const opts = vm.$el.options |
|
|
expect(opts[0].selected).toBe(false) |
|
|
expect(opts[0].selected).toBe(false) |
|
|
expect(opts[1].selected).toBe(true) |
|
|
expect(opts[1].selected).toBe(true) |
|
|
expect(opts[2].selected).toBe(false) |
|
|
expect(opts[2].selected).toBe(false) |
|
@ -272,7 +272,7 @@ describe('Directive v-model select', () => { |
|
|
'<option v-for="o in opts">{{ o }}</option>' + |
|
|
'<option v-for="o in opts">{{ o }}</option>' + |
|
|
'</select>' |
|
|
'</select>' |
|
|
}).$mount() |
|
|
}).$mount() |
|
|
var opts = vm.$el.options |
|
|
const opts = vm.$el.options |
|
|
expect(opts[0].selected).toBe(false) |
|
|
expect(opts[0].selected).toBe(false) |
|
|
expect(opts[1].selected).toBe(true) |
|
|
expect(opts[1].selected).toBe(true) |
|
|
expect(opts[2].selected).toBe(false) |
|
|
expect(opts[2].selected).toBe(false) |
|
@ -345,7 +345,7 @@ describe('Directive v-model select', () => { |
|
|
'<option selected>c</option>' + |
|
|
'<option selected>c</option>' + |
|
|
'</select>' |
|
|
'</select>' |
|
|
}).$mount() |
|
|
}).$mount() |
|
|
var opts = vm.$el.options |
|
|
const opts = vm.$el.options |
|
|
expect(opts[0].selected).toBe(true) |
|
|
expect(opts[0].selected).toBe(true) |
|
|
expect(opts[1].selected).toBe(true) |
|
|
expect(opts[1].selected).toBe(true) |
|
|
expect(opts[2].selected).toBe(true) |
|
|
expect(opts[2].selected).toBe(true) |
|
@ -379,8 +379,8 @@ describe('Directive v-model select', () => { |
|
|
'</div>' |
|
|
'</div>' |
|
|
}).$mount() |
|
|
}).$mount() |
|
|
document.body.appendChild(vm.$el) |
|
|
document.body.appendChild(vm.$el) |
|
|
var selects = vm.$el.getElementsByTagName('select') |
|
|
const selects = vm.$el.getElementsByTagName('select') |
|
|
var select0 = selects[0] |
|
|
const select0 = selects[0] |
|
|
select0.options[0].selected = true |
|
|
select0.options[0].selected = true |
|
|
triggerEvent(select0, 'change') |
|
|
triggerEvent(select0, 'change') |
|
|
waitForUpdate(() => { |
|
|
waitForUpdate(() => { |
|
@ -421,7 +421,7 @@ describe('Directive v-model select', () => { |
|
|
'<option value="true">c</option>' + |
|
|
'<option value="true">c</option>' + |
|
|
'</select>' |
|
|
'</select>' |
|
|
}).$mount() |
|
|
}).$mount() |
|
|
var opts = vm.$el.options |
|
|
const opts = vm.$el.options |
|
|
expect(opts[0].selected).toBe(false) |
|
|
expect(opts[0].selected).toBe(false) |
|
|
expect(opts[1].selected).toBe(true) |
|
|
expect(opts[1].selected).toBe(true) |
|
|
expect(opts[2].selected).toBe(false) |
|
|
expect(opts[2].selected).toBe(false) |
|
|