mathieustan / vue-datepicker

A clean datepicker made with VueJs
https://vue-datepicker.netlify.com/
MIT License
165 stars 47 forks source link

Bug: Passing `null` in range-mode causes errors #14

Closed kfirba closed 5 years ago

kfirba commented 5 years ago

It's me again,

Passing null as start/end values in range-mode (maybe even in single mode, haven't tested) causes errors.

data() {
      return {
        dates: {
          start: null,
          end: null,
        },
      };
    },

image

Surprisingly enough, changing the values to undefined solves the problem. I think this is a bug and null should be treated like undefined.

data() {
      return {
        dates: {
          start: undefined, // null should also be accepted?
          end: undefined, // // null should also be accepted?
        },
      };
    },
mathieustan commented 5 years ago

Hello there,

Apparently, it seems like dayjs treat null as an invalid date.

There is two way to init date range :

dates: undefined 

or

dates: { start: undefined, end: undefined }
kfirba commented 5 years ago

@mathieustan Alright. What if we turn null to undefined in the component itself instead of passing the raw value to dayjs? Are there any downsides to transforming null to undefined just before we pass the values to dayjs or when we accept the prop?

mathieustan commented 5 years ago

Closed. Done in v0.2.0