mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
refactor(fromJson): Remove error() and just throw
It's more likely you are using angular.fromJson() inside Angular world, which means you get proper exception handling by $exceptionHandler. There is no point to explicitly push it to console and it causes memory leaks on most browsers (tried Chrome stable/canary, Safari, FF).
This commit is contained in:
parent
512db03cc0
commit
b348347dad
2 changed files with 5 additions and 13 deletions
|
|
@ -83,9 +83,6 @@ var $boolean = 'boolean',
|
|||
slice = [].slice,
|
||||
push = [].push,
|
||||
toString = Object.prototype.toString,
|
||||
error = window[$console]
|
||||
? bind(window[$console], window[$console]['error'] || noop)
|
||||
: noop,
|
||||
|
||||
/** @name angular */
|
||||
angular = window.angular || (window.angular = {}),
|
||||
|
|
|
|||
15
src/JSON.js
15
src/JSON.js
|
|
@ -37,17 +37,12 @@ function fromJson(json, useNative) {
|
|||
|
||||
var obj;
|
||||
|
||||
try {
|
||||
if (useNative && window.JSON && window.JSON.parse) {
|
||||
obj = JSON.parse(json);
|
||||
} else {
|
||||
obj = parseJson(json, true)();
|
||||
}
|
||||
return transformDates(obj);
|
||||
} catch (e) {
|
||||
error("fromJson error: ", json, e);
|
||||
throw e;
|
||||
if (useNative && window.JSON && window.JSON.parse) {
|
||||
obj = JSON.parse(json);
|
||||
} else {
|
||||
obj = parseJson(json, true)();
|
||||
}
|
||||
return transformDates(obj);
|
||||
|
||||
// TODO make forEach optionally recursive and remove this function
|
||||
// TODO(misko): remove this once the $http service is checked in.
|
||||
|
|
|
|||
Loading…
Reference in a new issue