ArrobeFr/jquery-calendar-bs4

Code hangs on some datasets

igortyra opened this issue · 1 comments

In some situations the javascript code hangs into endless loop while trying to position events on the 'day' or 'week' grid.
Looks like it depends on dataset.
Fast way to reproduce issue (on week view):

calendar = $('#calendar').Calendar({
  locale: 'en',
  unixTimestamp: 1628373000,
  view: 'week',
  weekday: {
    timeline: {
      intervalMinutes: 30,
      fromHour: 6
    }
  },
  events: [
    {start:1628371000, end:1628373000, title: 'event1'},
    {start:1628371000, end:1628393000, title: 'event2'},
    {start:1628372000, end:1628375000, title: 'event3'},
    {start:1628373000, end:1628377000, title: 'event4'},
    {start:1628374000, end:1628378000, title: 'event5'},
  ],
  daynotes: [],
}).init();

the code works without event5 but hangs with it.

Hi,

I just stumbled upon a similar bug, and fixed it by changing:
for (e = 0; -1 == parseInt(currentElement.attr("data-positions")); ) {
to:
for (e = 0; -1 == parseInt(currentElement.attr("data-positions")) && e in o; ) {

This is on line 483 in jquery-calendar.no-modal.js