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

Commit 96f36d0

Browse files
committed
fix(datepicker): min-date/max-date: parse fix for literals
BREAKING CHANGE: only display formats or altInputFormats are valid for literal dates Closes #3437
1 parent 8bfeda0 commit 96f36d0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Diff for: src/datepicker/datepicker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,10 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi
628628
if (attrs[key]) {
629629
var getAttribute = $parse(attrs[key]);
630630
scope.$parent.$watch(getAttribute, function(value) {
631-
scope.watchData[key] = value;
632631
if (key === 'minDate' || key === 'maxDate') {
633-
cache[key] = new Date(value);
632+
cache[key] = new Date(parseDate(value));
634633
}
634+
scope.watchData[key] = cache[key] || value;
635635
});
636636
datepickerEl.attr(cameltoDash(key), 'watchData.' + key);
637637

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

+11
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,17 @@ describe('datepicker', function() {
19821982
expect(buttons.eq(0).prop('disabled')).toBe(true);
19831983
});
19841984

1985+
it('should disable today button if before min date, yyyy-MM-dd case', inject(function(dateFilter) {
1986+
var minDate = new Date(new Date().setDate(new Date().getDate() + 1));
1987+
var literalMinDate = dateFilter(minDate, 'yyyy-MM-dd');
1988+
var wrapElement = $compile('<div><input ng-model="date" uib-datepicker-popup="yyyy-MM-dd" min-date="\'' + literalMinDate + '\'" is-open="true"><div>')($rootScope);
1989+
$rootScope.$digest();
1990+
assignElements(wrapElement);
1991+
assignButtonBar();
1992+
1993+
expect(buttons.eq(0).prop('disabled')).toBe(true);
1994+
}));
1995+
19851996
it('should disable today button if after max date', function() {
19861997
$rootScope.maxDate = new Date().setDate(new Date().getDate() - 2);
19871998
var wrapElement = $compile('<div><input ng-model="date" uib-datepicker-popup max-date="maxDate" is-open="true"><div>')($rootScope);

0 commit comments

Comments
 (0)