if ( data === undefined && this.length ) {
data = jQuery.data( this[0], key );
}
+
return data === undefined && parts[1] ?
this.data( parts[0] ) :
data;
+
} else {
- return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ return this.each(function() {
+ var $this = jQuery( this ), args = [ parts[0], value ];
+
+ $this.triggerHandler( "setData" + parts[1] + "!", args );
jQuery.data( this, key, value );
- jQuery.event.trigger( "changeData" + parts[1] + "!", [parts[0], value], this );
+ $this.triggerHandler( "changeData" + parts[1] + "!", args );
});
}
},
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" );