X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fdata.js;h=8fb7f35adefcdc1fe15c965449ad1578461b61be;hb=714ae379db9dcb704c04080196a05d13a028f7a4;hp=1ce512c42813fc09121f12946a2a4cd39889aa75;hpb=7acb141ed7f2dedd950bb65acf878098640d081e;p=jquery.git diff --git a/test/unit/data.js b/test/unit/data.js index 1ce512c..8fb7f35 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -22,7 +22,7 @@ function dataTests (elem) { strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" ); var dataObj = jQuery.data(elem); - equals( typeof dataObj, elem.nodeType ? "object" : "function", "Calling data with no args gives us a data object reference" ); + equals( typeof dataObj, "object", "Calling data with no args gives us a data object reference" ); strictEqual( jQuery.data(elem), dataObj, "Calling jQuery.data returns the same data object when called multiple times" ); strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" ); @@ -180,7 +180,13 @@ test(".data()", function() { var div = jQuery("#foo"); strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" ); div.data("test", "success"); - same( div.data(), {test: "success"}, "data() get the entire data object" ); + + var dataObj = div.data(); + + // TODO: Remove this hack which was introduced in 1.5.1 + delete dataObj.toJSON; + + same( dataObj, {test: "success"}, "data() get the entire data object" ); strictEqual( div.data("foo"), undefined, "Make sure that missing result is still undefined" ); var nodiv = jQuery("#unfound"); @@ -189,7 +195,10 @@ test(".data()", function() { var obj = { foo: "bar" }; jQuery(obj).data("foo", "baz"); - var dataObj = jQuery.extend(true, {}, jQuery(obj).data()); + dataObj = jQuery.extend(true, {}, jQuery(obj).data()); + + // TODO: Remove this hack which was introduced for 1.5.1 + delete dataObj.toJSON; deepEqual( dataObj, { foo: "baz" }, "Retrieve data object from a wrapped JS object (#7524)" ); });