mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-05 19:42:27 +03:00
fix: split error when rangeSeparator is same as token
This commit is contained in:
@@ -382,6 +382,9 @@ describe('DatePicker', () => {
|
||||
input.trigger('change');
|
||||
input.setValue(`${text}${rangeSeparator.trim()}${text}`);
|
||||
input.trigger('change');
|
||||
expect(wrapper.emitted().input).toEqual([[[text, text]], [[text, text]]]);
|
||||
wrapper.setProps({ rangeSeparator: ' - ' });
|
||||
input.setValue(`${text} - ${text}`);
|
||||
input.trigger('change');
|
||||
expect(wrapper.emitted().input).toEqual([[[text, text]], [[text, text]], [[text, text]]]);
|
||||
});
|
||||
});
|
||||
|
||||
+10
-3
@@ -425,9 +425,16 @@ export default {
|
||||
this.handleClear();
|
||||
return;
|
||||
}
|
||||
const date = this.range
|
||||
? text.split(this.rangeSeparator.trim()).map(v => this.parseDate(v.trim(), this.format))
|
||||
: this.parseDate(text, this.format);
|
||||
let date;
|
||||
if (this.range) {
|
||||
let arr = text.split(this.rangeSeparator);
|
||||
if (arr.length !== 2) {
|
||||
arr = text.split(this.rangeSeparator.trim());
|
||||
}
|
||||
date = arr.map(v => this.parseDate(v.trim(), this.format));
|
||||
} else {
|
||||
date = this.parseDate(text, this.format);
|
||||
}
|
||||
if (this.isValidValue(date)) {
|
||||
this.emitValue(date);
|
||||
this.blur();
|
||||
|
||||
Reference in New Issue
Block a user