From bb0255f188b9c7e6ff47fcedddfb0e42b59c8fd9 Mon Sep 17 00:00:00 2001 From: xiemx Date: Tue, 17 Dec 2019 10:05:53 +0800 Subject: [PATCH] fix: shortcus with range (#400) --- __test__/date-picker.test.js | 13 +++++++++++++ src/date-picker.vue | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/__test__/date-picker.test.js b/__test__/date-picker.test.js index 166a51b0..d10cb37e 100644 --- a/__test__/date-picker.test.js +++ b/__test__/date-picker.test.js @@ -212,6 +212,19 @@ describe('DatePicker', () => { btn.trigger('click'); const emitted = wrapper.emitted(); expect(emitted.input).toEqual([['2019/05/10']]); + wrapper.setProps({ + range: true, + shortcuts: [ + { + text: 'range', + onClick() { + return [date, date]; + }, + }, + ], + }); + btn.trigger('click'); + expect(emitted.input[1]).toEqual([['2019/05/10', '2019/05/10']]); }); it('prop: popupClass', () => { diff --git a/src/date-picker.vue b/src/date-picker.vue index bd0fd740..dedfb871 100644 --- a/src/date-picker.vue +++ b/src/date-picker.vue @@ -379,7 +379,7 @@ export default { handleSelectShortcut(item) { if (isObject(item) && typeof item.onClick === 'function') { const date = item.onClick(this); - if (date instanceof Date) { + if (date) { this.emitValue(date); } }