fix(common): DatePipe doesn't throw for NaN (#14117)
Fixes #14103 PR Close #14117
This commit is contained in:
parent
670b680b0a
commit
7ad616a177
|
@ -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();
|
||||
|
|
|
@ -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(); });
|
||||
|
||||
|
|
Loading…
Reference in New Issue