diff options
| author | Vojta Jina | 2010-11-05 23:04:13 +0000 |
|---|---|---|
| committer | Igor Minar | 2010-11-05 21:39:00 -0700 |
| commit | b7027b9d8755604799781313e9bbd8eee72fc4f4 (patch) | |
| tree | c98800cee8d46dd9cfe408aaa765e956f3a058e4 /src/JSON.js | |
| parent | fe8353bc5e1cf8712655e8bb959165ee660bce26 (diff) | |
| download | angular.js-b7027b9d8755604799781313e9bbd8eee72fc4f4.tar.bz2 | |
Updated toJson() to not serialize window/document objects.
The reason to void these to objects is that they cause all sorts
of problems like exceptions being thrown and infinite loops occuring
when we iterate over object properties.
Diffstat (limited to 'src/JSON.js')
| -rw-r--r-- | src/JSON.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/JSON.js b/src/JSON.js index 9ec95805..50f63dec 100644 --- a/src/JSON.js +++ b/src/JSON.js @@ -22,8 +22,18 @@ function fromJson(json) { angular['toJson'] = toJson; angular['fromJson'] = fromJson; -function toJsonArray(buf, obj, pretty, stack){ - if (typeof obj == "object") { +function toJsonArray(buf, obj, pretty, stack) { + if (isObject(obj)) { + if (obj === window) { + buf.push('WINDOW'); + return; + } + + if (obj === document) { + buf.push('DOCUMENT'); + return; + } + if (includes(stack, obj)) { buf.push("RECURSION"); return; |
