Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Fixed "reduce is not a function" errors. #494

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ angular.module('ui.calendar', [])
.controller('uiCalendarCtrl', ['$scope', '$locale',
function ($scope, $locale) {

var sources = $scope.eventSources;
var sources = typeof ($scope.eventSources) !== "undefined" && $scope.eventSources !== null ? $scope.eventSources : [];
var extraEventSignature = $scope.calendarWatchEvent ? $scope.calendarWatchEvent : angular.noop;

var wrapFunctionWithScopeApply = function (functionToWrap) {
Expand Down Expand Up @@ -70,7 +70,7 @@ angular.module('ui.calendar', [])
this.allEvents = function () {
return Array.prototype.concat.apply(
[],
(sources || []).reduce(
(Array.from(sources) || []).reduce(
function (previous, source) {
if (angular.isArray(source)) {
previous.push(source);
Expand Down Expand Up @@ -108,7 +108,7 @@ angular.module('ui.calendar', [])
var self;

var getTokens = function () {
return ((angular.isFunction(arraySource) ? arraySource() : arraySource) || []).reduce(
return (Array.from(angular.isFunction(arraySource) ? arraySource() : arraySource) || []).reduce(
function (rslt, el) {
var token = tokenFn(el);
map[token] = el;
Expand Down Expand Up @@ -240,7 +240,7 @@ angular.module('ui.calendar', [])
},
controller : 'uiCalendarCtrl',
link : function (scope, elm, attrs, controller) {
var sources = scope.eventSources;
var sources = typeof (scope.eventSources) !== "undefined" && scope.eventSources !== null ? scope.eventSources : [];
var sourcesChanged = false;
var calendar;
var eventSourcesWatcher = controller.changeWatcher(sources, controller.sourceFingerprint);
Expand Down Expand Up @@ -362,4 +362,4 @@ angular.module('ui.calendar', [])
};
}
]
);
);