Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix(datepicker): init-date: check if parsed value is valid #5266

Closed
wants to merge 1 commit into from
Closed

fix(datepicker): init-date: check if parsed value is valid #5266

wants to merge 1 commit into from

Conversation

AndriIushchuk
Copy link
Contributor

Closes #5190

@wesleycho
Copy link
Contributor

Can you take a look at what broke the unit test here in this change?

@@ -71,10 +71,12 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
$scope.uniqueId = 'datepicker-' + $scope.$id + '-' + Math.floor(Math.random() * 10000);

if (angular.isDefined($attrs.initDate)) {
this.activeDate = dateParser.fromTimezone($scope.$parent.$eval($attrs.initDate), ngModelOptions.timezone) || new Date();
var initDate = dateParser.fromTimezone($scope.$parent.$eval($attrs.initDate), ngModelOptions.timezone);
this.activeDate = !isNaN(initDate) ? initDate : new Date();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this with the initDate and setting to this.activeDate can be abstracted out to a common helper function to avoid duplicated code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case this.activeDate changes and below - self.activeDate

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants