Permalink
Browse files

Fixed mootools compatibility problem in client/json2.js.

  • Loading branch information...
1 parent 2c56eef commit 26a8b87788cd5556c4796844fff5b7fc454ebd3a @ivan4th ivan4th committed Feb 21, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 client/json2.js
View
@@ -238,9 +238,11 @@ if (!this.JSON) {
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
-
if (value && typeof value === 'object' &&
- typeof value.toJSON === 'function') {
+ typeof value.toJSON === 'function' &&
+ // avoid problem with mootools
+ (!Array.prototype.toJSON ||
+ Object.prototype.toString.apply(value) !== '[object Array]')) {
value = value.toJSON(key);
}
@@ -252,7 +254,6 @@ if (!this.JSON) {
}
// What happens next depends on the value's type.
-
switch (typeof value) {
case 'string':
return quote(value);

0 comments on commit 26a8b87

Please sign in to comment.