Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Only perpetrate the .toJSON hack on data caches when they are attache…

…d to a plain Javascript object. Part of the continuing saga of #8108.
  • Loading branch information...
commit b9f5e2b97458f89cbcac3a333ba95b0eac568d49 1 parent 5b38439
@dmethvin dmethvin authored jitter committed
Showing with 10 additions and 7 deletions.
  1. +10 −1 src/data.js
  2. +0 −6 test/unit/data.js
View
11 src/data.js
@@ -68,7 +68,9 @@ jQuery.extend({
// TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
// metadata on plain JS objects when the object is serialized using
// JSON.stringify
- cache[ id ].toJSON = jQuery.noop;
+ if ( !isNode ) {
+ cache[ id ].toJSON = jQuery.noop;
+ }
}
// An object can be passed to jQuery.data instead of a key/value pair; this gets
@@ -168,6 +170,13 @@ jQuery.extend({
// data if it existed
if ( internalCache ) {
cache[ id ] = {};
+ // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
+ // metadata on plain JS objects when the object is serialized using
+ // JSON.stringify
+ if ( !isNode ) {
+ cache[ id ].toJSON = jQuery.noop;
+ }
+
cache[ id ][ internalKey ] = internalCache;
// Otherwise, we need to eliminate the expando on the node to avoid
View
6 test/unit/data.js
@@ -338,18 +338,12 @@ test("data-* attributes", function() {
num++;
}
- // TODO: Remove this hack which was introduced for 1.5.1
- num--;
-
equals( num, check.length, "Make sure that the right number of properties came through." );
for ( var prop in obj2 ) {
num2++;
}
- // TODO: Remove this hack which was introduced for 1.5.1
- num2--;
-
equals( num2, check.length, "Make sure that the right number of properties came through." );
child.attr("data-other", "newvalue");
Please sign in to comment.
Something went wrong with that request. Please try again.