fix(common): DatePipe doesn't throw for NaN (#14117)

Fixes #14103

PR Close #14117
This commit is contained in:
Dzmitry Shylovich 2017-01-26 18:23:53 +03:00 committed by Miško Hevery
parent 670b680b0a
commit 7ad616a177
2 changed files with 3 additions and 1 deletions

View File

@ -103,7 +103,7 @@ export class DatePipe implements PipeTransform {
transform(value: any, pattern: string = 'mediumDate'): string {
let date: Date;
if (isBlank(value)) return null;
if (isBlank(value) || value !== value) return null;
if (typeof value === 'string') {
value = value.trim();

View File

@ -53,6 +53,8 @@ export function main() {
it('should return null for empty string', () => expect(pipe.transform('')).toEqual(null));
it('should return null for NaN', () => expect(pipe.transform(Number.NaN)).toEqual(null));
it('should support ISO string without time',
() => { expect(() => pipe.transform(isoStringWithoutTime)).not.toThrow(); });