Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1334b8c

Browse files
pkozlowski-opensourcelgalfaso
authored andcommitted
fix(dateFilter): ignore invalid dates
Fixes #10640
1 parent d2a9a16 commit 1334b8c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/ng/filter/filters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ function dateFilter($locale) {
459459
date = new Date(date);
460460
}
461461

462-
if (!isDate(date)) {
462+
if (!isDate(date) || !isFinite(date.getTime())) {
463463
return date;
464464
}
465465

test/ng/filter/filtersSpec.js

+5
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ describe('filters', function() {
247247
expect(date('')).toEqual('');
248248
});
249249

250+
it('should ignore invalid dates', function() {
251+
var invalidDate = new Date('abc');
252+
expect(date(invalidDate)).toBe(invalidDate);
253+
});
254+
250255
it('should do basic filter', function() {
251256
expect(date(noon)).toEqual(date(noon, 'mediumDate'));
252257
expect(date(noon, '')).toEqual(date(noon, 'mediumDate'));

0 commit comments

Comments
 (0)