From 4f2e39aefda831bda6ad3f077febb406128f072e Mon Sep 17 00:00:00 2001 From: Diego Date: Wed, 5 Apr 2017 11:26:36 +0100 Subject: [PATCH] check for altInputFormats to be defined and an array If the user wrongly sets a property which is undefined for the attribute alt-input-formats, this will cause an exception to be thrown when evaluating the viewValue in the method parseDateString: "Cannot read property 'length' of undefined". Checking for its existence and if it's an array or not prevents the exception. --- src/datepickerPopup/popup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datepickerPopup/popup.js b/src/datepickerPopup/popup.js index 02c0e88a1c..6baa936a49 100644 --- a/src/datepickerPopup/popup.js +++ b/src/datepickerPopup/popup.js @@ -301,7 +301,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $ function parseDateString(viewValue) { var date = dateParser.parse(viewValue, dateFormat, $scope.date); - if (isNaN(date)) { + if (isNaN(date) && angular.isArray(altInputFormats)) { for (var i = 0; i < altInputFormats.length; i++) { date = dateParser.parse(viewValue, altInputFormats[i], $scope.date); if (!isNaN(date)) {