correct behaviour when initialising date-picker with a empty string
This commit is contained in:
parent
109465d3c5
commit
5d1c24c7f4
2 changed files with 27 additions and 12 deletions
|
@ -517,7 +517,7 @@
|
||||||
val = val.join(RANGE_SEPARATOR);
|
val = val.join(RANGE_SEPARATOR);
|
||||||
val = parser(val, this.format || DEFAULT_FORMATS[type]);
|
val = parser(val, this.format || DEFAULT_FORMATS[type]);
|
||||||
} else if (typeof val === 'string' && type.indexOf('time') !== 0 ){
|
} else if (typeof val === 'string' && type.indexOf('time') !== 0 ){
|
||||||
val = parser(val, this.format || DEFAULT_FORMATS[type]);
|
val = parser(val, this.format || DEFAULT_FORMATS[type]) || val;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.internalValue = val;
|
this.internalValue = val;
|
||||||
|
|
|
@ -103,19 +103,19 @@ describe('DatePicker.vue', () => {
|
||||||
|
|
||||||
vm.dateType = 'year';
|
vm.dateType = 'year';
|
||||||
promissedTick(picker)
|
promissedTick(picker)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
expect(picker.type).to.equal('year');
|
expect(picker.type).to.equal('year');
|
||||||
expect(picker.selectionMode).to.equal('year');
|
expect(picker.selectionMode).to.equal('year');
|
||||||
|
|
||||||
vm.dateType = 'date';
|
vm.dateType = 'date';
|
||||||
return promissedTick(picker);
|
return promissedTick(picker);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
expect(picker.type).to.equal('date');
|
expect(picker.type).to.equal('date');
|
||||||
expect(picker.selectionMode).to.equal('day');
|
expect(picker.selectionMode).to.equal('day');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -176,4 +176,19 @@ describe('DatePicker.vue', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should accept a empty string as input v-model value', done => {
|
||||||
|
vm = createVue({
|
||||||
|
template: '<date-picker v-model="value" type="date"></date-picker>',
|
||||||
|
data(){
|
||||||
|
return {value: ''};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
vm.$nextTick(() => {
|
||||||
|
expect(vm.value).to.equal('');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue