module("data");
test("expando", function(){
- expect(6);
+ expect(7);
equals("expando" in jQuery, true, "jQuery is exposing the expando");
var obj = {};
jQuery.data(obj);
equals( jQuery.expando in obj, true, "jQuery.data adds an expando to the object" );
+ equals( typeof obj[jQuery.expando], "function", "jQuery.data adds an expando to the object as a function" );
obj = {};
jQuery.data(obj, 'test');
jQuery.data(obj, "foo", "bar");
equals( jQuery.expando in obj, true, "jQuery.data added an expando to the object" );
- var id = obj[jQuery.expando];
+ var id = obj[jQuery.expando]();
equals( id in jQuery.cache, false, "jQuery.data did not add an entry to jQuery.cache" );
equals( id.foo, "bar", "jQuery.data worked correctly" );
jQuery.data( obj, "prop", true );
ok( obj[ jQuery.expando ], "Data is being stored on the object." );
- ok( obj[ jQuery.expando ].prop, "Data is being stored on the object." );
+ ok( obj[ jQuery.expando ]().prop, "Data is being stored on the object." );
equals( jQuery.data( obj, "prop" ), true, "Make sure the right value is retrieved." );
});
test(".data(String) and .data(String, Object)", function() {
expect(27);
- var div = jQuery("<div/>");
+ var parent = jQuery("<div><div></div></div>"),
+ div = parent.children();
+
+ parent
+ .bind("getData", function(){ ok( false, "getData bubbled." ) })
+ .bind("setData", function(){ ok( false, "setData bubbled." ) })
+ .bind("changeData", function(){ ok( false, "changeData bubbled." ) });
ok( div.data("test") === undefined, "Check for no data exists" );