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

Commit ab4580f

Browse files
committedAug 1, 2015
fix(datepicker): *BREAKING CHANGE* remove new Date fallback
- Remove `new Date` fallback due to buggy behavior Closes #2513 Closes #3294 Closes #3344 Closes #3682 Closes #4092 Fixes #1289 Fixes #2446 Fixes #3037 Fixes #3104 Fixes #3196 Fixes #3206 Fixes #3342 Fixes #3617 Fixes #3644
1 parent 2004757 commit ab4580f

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed
 

Diff for: ‎src/datepicker/datepicker.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi
602602
} else if (angular.isDate(viewValue) && !isNaN(viewValue)) {
603603
return viewValue;
604604
} else if (angular.isString(viewValue)) {
605-
var date = dateParser.parse(viewValue, dateFormat, scope.date) || new Date(viewValue);
605+
var date = dateParser.parse(viewValue, dateFormat, scope.date);
606606
if (isNaN(date)) {
607607
return undefined;
608608
} else {
@@ -628,7 +628,7 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi
628628
} else if (angular.isDate(value) && !isNaN(value)) {
629629
return true;
630630
} else if (angular.isString(value)) {
631-
var date = dateParser.parse(value, dateFormat) || new Date(value);
631+
var date = dateParser.parse(value, dateFormat);
632632
return !isNaN(date);
633633
} else {
634634
return false;
@@ -669,7 +669,7 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi
669669

670670
// Detect changes in the view from the text box
671671
ngModel.$viewChangeListeners.push(function () {
672-
scope.date = dateParser.parse(ngModel.$viewValue, dateFormat, scope.date) || new Date(ngModel.$viewValue);
672+
scope.date = dateParser.parse(ngModel.$viewValue, dateFormat, scope.date);
673673
});
674674

675675
var documentClickBind = function(event) {

Diff for: ‎src/datepicker/test/datepicker.spec.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1276,21 +1276,21 @@ describe('datepicker directive', function () {
12761276
});
12771277

12781278
it('updates the model & calendar when input value changes', function() {
1279-
changeInputValueTo(inputEl, 'March 5, 1980');
1279+
changeInputValueTo(inputEl, '2010-09-15');
12801280

1281-
expect($rootScope.date.getFullYear()).toEqual(1980);
1282-
expect($rootScope.date.getMonth()).toEqual(2);
1283-
expect($rootScope.date.getDate()).toEqual(5);
1281+
expect($rootScope.date.getFullYear()).toEqual(2010);
1282+
expect($rootScope.date.getMonth()).toEqual(8);
1283+
expect($rootScope.date.getDate()).toEqual(15);
12841284

12851285
expect(getOptions(true)).toEqual([
1286-
['24', '25', '26', '27', '28', '29', '01'],
1287-
['02', '03', '04', '05', '06', '07', '08'],
1288-
['09', '10', '11', '12', '13', '14', '15'],
1289-
['16', '17', '18', '19', '20', '21', '22'],
1290-
['23', '24', '25', '26', '27', '28', '29'],
1291-
['30', '31', '01', '02', '03', '04', '05']
1286+
['29', '30', '31', '01', '02', '03', '04'],
1287+
['05', '06', '07', '08', '09', '10', '11'],
1288+
['12', '13', '14', '15', '16', '17', '18'],
1289+
['19', '20', '21', '22', '23', '24', '25'],
1290+
['26', '27', '28', '29', '30', '01', '02'],
1291+
['03', '04', '05', '06', '07', '08', '09']
12921292
]);
1293-
expectSelectedElement( 10 );
1293+
expectSelectedElement( 17 );
12941294
});
12951295

12961296
it('closes when click outside of calendar', function() {
@@ -1389,7 +1389,7 @@ describe('datepicker directive', function () {
13891389
}));
13901390

13911391
it('should change model and update calendar after debounce timeout', function() {
1392-
changeInputValueTo(inputEl, 'March 5, 1980');
1392+
changeInputValueTo(inputEl, '1980-03-05');
13931393

13941394
expect($rootScope.date.getFullYear()).toEqual(2010);
13951395
expect($rootScope.date.getMonth()).toEqual(9 - 1);

0 commit comments

Comments
 (0)