X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fevent%2Fevent.js;h=a3db2f3ab0bcb501fe85903d0175c4e253913390;hb=2897b1bd2383031b6764192dc1ccb1d1205139a3;hp=3834fd65f53e21c41971dff4a6621510c12f5cb7;hpb=1d2faf36cf356bc09d3389ad6fce6ee520560f25;p=jquery.git diff --git a/src/event/event.js b/src/event/event.js index 3834fd6..a3db2f3 100644 --- a/src/event/event.js +++ b/src/event/event.js @@ -32,8 +32,11 @@ jQuery.event = { } // Make sure that the function being executed has a unique ID - if ( !handler.guid ) + if ( !handler.guid ) { handler.guid = this.guid++; + // Don't forget to set guid for the original handler function + if (fn) fn.guid = handler.guid; + } // Init the element's event structure if (!element.$events) @@ -55,7 +58,7 @@ jQuery.event = { if (element.addEventListener) element.addEventListener(type, element.$handle, false); else if (element.attachEvent) - element.attachEvent("on" + type, element.$handle, false); + element.attachEvent("on" + type, element.$handle); } // Add the function to the element's handler list @@ -101,7 +104,7 @@ jQuery.event = { if (element.removeEventListener) element.removeEventListener(type, element.$handle, false); else if (element.detachEvent) - element.detachEvent("on" + type, element.$handle, false); + element.detachEvent("on" + type, element.$handle); ret = null; delete events[type]; } @@ -274,7 +277,7 @@ jQuery.fn.extend({ */ bind: function( type, data, fn ) { return this.each(function(){ - jQuery.event.add( this, type, fn || data, data ); + jQuery.event.add( this, type, fn || data, fn && data ); }); }, @@ -309,7 +312,7 @@ jQuery.fn.extend({ jQuery.event.add( this, type, function(event) { jQuery(this).unbind(event); return (fn || data).apply( this, arguments); - }, data); + }, fn && data); }); },