Only perpetrate the .toJSON hack on data caches when they are attached to a plain Javascript object. Part of the continuing saga of #8108.
This commit is contained in:
parent
5b38439011
commit
b9f5e2b974
|
@ -68,8 +68,10 @@ jQuery.extend({
|
||||||
// TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
|
// TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
|
||||||
// metadata on plain JS objects when the object is serialized using
|
// metadata on plain JS objects when the object is serialized using
|
||||||
// JSON.stringify
|
// JSON.stringify
|
||||||
|
if ( !isNode ) {
|
||||||
cache[ id ].toJSON = jQuery.noop;
|
cache[ id ].toJSON = jQuery.noop;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// An object can be passed to jQuery.data instead of a key/value pair; this gets
|
// An object can be passed to jQuery.data instead of a key/value pair; this gets
|
||||||
// shallow copied over onto the existing cache
|
// shallow copied over onto the existing cache
|
||||||
|
@ -168,6 +170,13 @@ jQuery.extend({
|
||||||
// data if it existed
|
// data if it existed
|
||||||
if ( internalCache ) {
|
if ( internalCache ) {
|
||||||
cache[ id ] = {};
|
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;
|
cache[ id ][ internalKey ] = internalCache;
|
||||||
|
|
||||||
// Otherwise, we need to eliminate the expando on the node to avoid
|
// Otherwise, we need to eliminate the expando on the node to avoid
|
||||||
|
|
|
@ -338,18 +338,12 @@ test("data-* attributes", function() {
|
||||||
num++;
|
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." );
|
equals( num, check.length, "Make sure that the right number of properties came through." );
|
||||||
|
|
||||||
for ( var prop in obj2 ) {
|
for ( var prop in obj2 ) {
|
||||||
num2++;
|
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." );
|
equals( num2, check.length, "Make sure that the right number of properties came through." );
|
||||||
|
|
||||||
child.attr("data-other", "newvalue");
|
child.attr("data-other", "newvalue");
|
||||||
|
|
Loading…
Reference in a new issue