jquery data: closes #5224. Exposing the expando.

This commit is contained in:
Ariel Flesler 2009-09-14 22:34:04 +00:00
parent 173c1477ae
commit a273120291
2 changed files with 18 additions and 0 deletions

View file

@ -2,6 +2,8 @@ var expando = "jQuery" + now(), uuid = 0, windowData = {};
jQuery.extend({
cache: {},
expando:expando,
data: function( elem, name, data ) {
elem = elem == window ?

View file

@ -1,5 +1,21 @@
module("data");
test("expando", function(){
expect(4);
equals("expando" in jQuery, true, "jQuery is exposing the expando");
var obj = {};
jQuery.data(obj, "foo", "bar");
equals(jQuery.expando in obj, true, "jQuery.data added an expando to the object");
var id = obj[jQuery.expando];
equals( id in jQuery.cache, true, "jQuery.data added an entry to jQuery.cache");
equals( jQuery.cache[id].foo, "bar", "jQuery.data worked correctly");
});
test("jQuery.data", function() {
expect(5);
var div = jQuery("#foo")[0];