jquery data: closes #5224. Exposing the expando.
authorAriel Flesler <aflesler@gmail.com>
Mon, 14 Sep 2009 22:34:04 +0000 (22:34 +0000)
committerAriel Flesler <aflesler@gmail.com>
Mon, 14 Sep 2009 22:34:04 +0000 (22:34 +0000)
src/data.js
test/unit/data.js

index 03116e4..d03d51f 100644 (file)
@@ -2,6 +2,8 @@ var expando = "jQuery" + now(), uuid = 0, windowData = {};
 \r
 jQuery.extend({\r
        cache: {},\r
+       \r
+       expando:expando,\r
 \r
        data: function( elem, name, data ) {\r
                elem = elem == window ?\r
index 6b79da2..46e46ed 100644 (file)
@@ -1,5 +1,21 @@
 module("data");\r
 \r
+test("expando", function(){\r
+       expect(4);\r
+       \r
+       equals("expando" in jQuery, true, "jQuery is exposing the expando");\r
+       \r
+       var obj = {};\r
+       jQuery.data(obj, "foo", "bar");\r
+\r
+       equals(jQuery.expando in obj, true, "jQuery.data added an expando to the object");      \r
+       \r
+       var id = obj[jQuery.expando];\r
+       equals( id in jQuery.cache, true, "jQuery.data added an entry to jQuery.cache");\r
+       \r
+       equals( jQuery.cache[id].foo, "bar", "jQuery.data worked correctly");\r
+});\r
+\r
 test("jQuery.data", function() {\r
        expect(5);\r
        var div = jQuery("#foo")[0];\r