ember-power-calendar icon indicating copy to clipboard operation
ember-power-calendar copied to clipboard

firefox moment issue.

Open koryteg opened this issue 8 years ago • 8 comments

firefox is freezing when hitting this method if you pass a moment.js date object to the addon.

    lastDay: function lastDay(calendar) {
      var localeStartOfWeek = this.get('localeStartOfWeek');
      var lastDay = calendar.center.clone().endOf('month');
      var localeEndOfWeek = (localeStartOfWeek + 6) % 7;
      while (lastDay.isoWeekday() % 7 !== localeEndOfWeek) {
        lastDay.add(1, 'day');
      }
      return lastDay;
    },

koryteg avatar Dec 20 '16 19:12 koryteg

@koryteg only firefox? Interesting. I'll check it. Can you check if the tests pass on firefox and if they do, create a failing test that exercises this error?

cibernox avatar Dec 20 '16 23:12 cibernox

yeah I will try and get something going on a PR.

koryteg avatar Dec 21 '16 23:12 koryteg

We had a similar issue recently, but it got both Chrome and Firefox freezing. I tracked it down to passing null as the selected date to the calendar. However it might be the same issue.

boyanyordanov avatar Feb 15 '17 19:02 boyanyordanov

@boyanyordanov how did you resolve? does selected date accept an empty object just as well?

bahdvp avatar Aug 07 '17 16:08 bahdvp

FWIW, I did not find a way to reproduce this, but I suspect the reason. There is a part of the code where I compare dates on a while and keep iterating until a date is before or after another one. So far so good, but if the moment is malformed, that loop never ends causing the freeze.

Why can that happen in one browser and not in another? Because the only date format that is guaranteed to work in all browsers is ISO 8601. Any other format may or may not work. Chrome per example is pretty good at parsing malformed dates. Firefox is more strict.

I suspect this is the root cause, if anyone wants to investigate.

cibernox avatar Aug 07 '17 16:08 cibernox

We've run into this issue as well.

I believe our test case for the fix was something like:

{{power-calendar date="Invalid Date"}}

Or something similar

NLincoln avatar Aug 07 '17 16:08 NLincoln

@NLincoln Cheers.

@cibernox I have not been able to reproduce either. A tester reported it as an issue but didn't see an immediate cause. If I ever get time to investigate further I'll let you know. Thanks for the lead.

bahdvp avatar Aug 07 '17 16:08 bahdvp

@bahdvp I am sorry, I was not able to write earlier. We just don't initialize the values and have checks in the parent component to ensure we always pass down a valid date.

boyanyordanov avatar Aug 13 '17 15:08 boyanyordanov