This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1235,6 +1235,27 @@ function toJsonReplacer(key, value) {
1235
1235
* @param {boolean|number } [pretty=2] If set to true, the JSON output will contain newlines and whitespace.
1236
1236
* If set to an integer, the JSON output will contain that many spaces per indentation.
1237
1237
* @returns {string|undefined } JSON-ified string representing `obj`.
1238
+ * @knownIssue
1239
+ *
1240
+ * The Safari browser throws a `RangeError` instead of returning `null` when it tries to stringify a `Date`
1241
+ * object with an invalid date value. The only reliable way to prevent this is to monkeypatch the
1242
+ * `Date.prototype.toJSON` method as follows:
1243
+ *
1244
+ * ```
1245
+ * var _DatetoJSON = Date.prototype.toJSON;
1246
+ * Date.prototype.toJSON = function() {
1247
+ * try {
1248
+ * return _DatetoJSON.call(this);
1249
+ * } catch(e) {
1250
+ * if (e instanceof RangeError) {
1251
+ * return null;
1252
+ * }
1253
+ * throw e;
1254
+ * }
1255
+ * };
1256
+ * ```
1257
+ *
1258
+ * See https://github.com/angular/angular.js/pull/14221 for more information.
1238
1259
*/
1239
1260
function toJson ( obj , pretty ) {
1240
1261
if ( isUndefined ( obj ) ) return undefined ;
You can’t perform that action at this time.
0 commit comments