This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Date Filter: Safari throws error if the date is an Invalid Date. #13415
Closed
Description
Safari's JSON.stringify
doesn't handle invalid dates correctly. It throws a RangeError: Invalid Date
.
Whenever you try to interpolate an Invalid Date
with the date filter, it breaks.
{{ 1/0 | date }}
http://plnkr.co/edit/z8xKljNoR1GdsMQypzlq?p=preview
In https://github.com/angular/angular.js/blob/master/src/ng/interpolate.js
parseStringifyInterceptor
> stringify
> toJson
> JSON.stringify
This issue might be too specific for a fix to be included in Angular though. Thoughts ?
I'd be glad to provide a PR.
Something along :
if(isNaN(date.getTime())){
return '';
}
here https://github.com/angular/angular.js/blob/master/src/ng/filter/filters.js#L489