Skip to content

Commit b924281

Browse files
author
Jeff
committed
fix isValueEmpty bug when working with integers
1 parent 7989302 commit b924281

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/components/Select.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,9 +1080,9 @@
10801080
isValueEmpty() {
10811081
if (this.mutableValue) {
10821082
if (typeof this.mutableValue === 'object') {
1083-
return !Object.keys(this.mutableValue).length
1083+
return ! Object.keys(this.mutableValue).length
10841084
}
1085-
return !this.mutableValue.length
1085+
return ! this.valueAsArray.length
10861086
}
10871087
10881088
return true;

test/unit/specs/Select.spec.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,20 @@ describe('Select.vue', () => {
249249
expect(vm.$children[0].isOptionSelected('foo')).toEqual(true)
250250
}),
251251

252-
describe('change Event', () => {
252+
it('can work with an array of integers', () => {
253+
const vm = new Vue({
254+
template: '<div><v-select :options="[1,2,3,4,5]" v-model="value"></v-select></div>',
255+
components: {vSelect},
256+
data: {
257+
value: 5,
258+
}
259+
}).$mount()
260+
261+
expect(vm.$children[0].isOptionSelected(5)).toEqual(true)
262+
expect(vm.$children[0].isValueEmpty).toEqual(false)
263+
})
264+
265+
describe('change Event', () => {
253266
it('will trigger the input event when the selection changes', (done) => {
254267
const vm = new Vue({
255268
template: `<div><v-select ref="select" :value="['foo']" :options="['foo','bar','baz']" v-on:input="foo = arguments[0]"></v-select></div>`,
@@ -1564,7 +1577,7 @@ describe('Select.vue', () => {
15641577
})
15651578
})
15661579

1567-
describe( 'Clear button', () => {
1580+
describe('Clear button', () => {
15681581

15691582
it( 'should be displayed on single select when value is selected', () => {
15701583
const VueSelect = Vue.extend( vSelect )

0 commit comments

Comments
 (0)