if ( special.add ) {
special.add.call( elem, handleObj );
+
+ if ( !handleObj.handler.guid ) {
+ handleObj.handler.guid = handler.guid;
+ }
}
// Add the function to the element's handler list
},
cleanData: function( elems ) {
- var data, id, cache = jQuery.cache;
+ var data, id, cache = jQuery.cache, special = jQuery.event.special;
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
id = elem[ jQuery.expando ];
data = cache[ id ];
if ( data.events ) {
- for ( var event in data.events ) {
- removeEvent( elem, event, data.handle );
+ for ( var type in data.events ) {
+ if ( special[ type ] ) {
+ jQuery.event.remove( elem, type );
+
+ } else {
+ removeEvent( elem, type, data.handle );
+ }
}
}
});
test("bind(), namespace with special add", function() {
- expect(19);
+ expect(24);
var div = jQuery("<div/>").bind("test", function(e) {
ok( true, "Test event fired." );
handler.apply( this, arguments );
};
},
- remove: function() {}
+ remove: function() {
+ ok(true, "Remove called.");
+ }
};
div.bind("test.a", {x: 1}, function(e) {
// Should trigger 2
div.trigger("test.b");
+ // Should trigger 4
div.unbind("test");
+
+ div = jQuery("<div/>").bind("test", function(e) {
+ ok( true, "Test event fired." );
+ });
+
+ // Should trigger 2
+ div.appendTo("#main").remove();
+
+ delete jQuery.event.special.test;
});
test("bind(), no data", function() {