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 @@ -1233,6 +1233,27 @@ function toJsonReplacer(key, value) {
12331233 * @param {boolean|number } [pretty=2] If set to true, the JSON output will contain newlines and whitespace.
12341234 * If set to an integer, the JSON output will contain that many spaces per indentation.
12351235 * @returns {string|undefined } JSON-ified string representing `obj`.
1236+ * @knownIssue
1237+ *
1238+ * The Safari browser throws a `RangeError` instead of returning `null` when it tries to stringify a `Date`
1239+ * object with an invalid date value. The only reliable way to prevent this is to monkeypatch the
1240+ * `Date.prototype.toJSON` method as follows:
1241+ *
1242+ * ```
1243+ * var _DatetoJSON = Date.prototype.toJSON;
1244+ * Date.prototype.toJSON = function() {
1245+ * try {
1246+ * return _DatetoJSON.call(this);
1247+ * } catch(e) {
1248+ * if (e instanceof RangeError) {
1249+ * return null;
1250+ * }
1251+ * throw e;
1252+ * }
1253+ * };
1254+ * ```
1255+ *
1256+ * See https://github.com/angular/angular.js/pull/14221 for more information.
12361257 */
12371258function toJson ( obj , pretty ) {
12381259 if ( isUndefined ( obj ) ) return undefined ;
You can’t perform that action at this time.
0 commit comments