X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fevent%2Fevent.js;h=eaf6858c53cd6c1a31f7de9cf199f08290750ecb;hb=783f589fbf005a6a3211bff20e3e8aeb1ea0ac22;hp=d2609ccbe36bf0341b68e68084f418f0528d1e8a;hpb=0ae7198b9e1614be54eecb5bb0272094996397d9;p=jquery.git diff --git a/src/event/event.js b/src/event/event.js index d2609cc..eaf6858 100644 --- a/src/event/event.js +++ b/src/event/event.js @@ -82,11 +82,15 @@ jQuery.event = { // Handle triggering a single element } else if ( element["on" + type] ) { - // Pass along a fake event - data.unshift( this.fix({ type: type, target: element }) ); - - // Trigger the event - element["on" + type].apply( element, data ); + if ( element[ type ] && element[ type ].constructor == Function ) + element[ type ](); + else { + // Pass along a fake event + data.unshift( this.fix({ type: type, target: element }) ); + + // Trigger the event + element["on" + type].apply( element, data ); + } } }, @@ -136,7 +140,7 @@ jQuery.event = { } // check if target is a textnode (safari) - if (event.target.nodeType == 3) { + if (jQuery.browser.safari && event.target.nodeType == 3) { // store a copy of the original event object // and clone because target is read only var originalEvent = event; @@ -261,43 +265,31 @@ jQuery.fn.extend({ /** * The opposite of bind, removes a bound event from each of the matched - * elements. You must pass the identical function that was used in the original - * bind method. + * elements. * - * @example $("p").unbind( "click", function() { alert("Hello"); } ) + * Without any arguments, all bound events are removed. + * + * If the type is provided, all bound events of that type are removed. + * + * If the function that was passed to bind is provided as the second argument, + * only that specific event handler is removed. + * + * @example $("p").unbind() * @before

Hello

* @result [

Hello

] * - * @name unbind - * @type jQuery - * @param String type An event type - * @param Function fn A function to unbind from the event on each of the set of matched elements - * @cat Events - */ - - /** - * Removes all bound events of a particular type from each of the matched - * elements. - * * @example $("p").unbind( "click" ) * @before

Hello

* @result [

Hello

] * - * @name unbind - * @type jQuery - * @param String type An event type - * @cat Events - */ - - /** - * Removes all bound events from each of the matched elements. - * - * @example $("p").unbind() + * @example $("p").unbind( "click", function() { alert("Hello"); } ) * @before

Hello

* @result [

Hello

] * * @name unbind * @type jQuery + * @param String type (optional) An event type + * @param Function fn (optional) A function to unbind from the event on each of the set of matched elements * @cat Events */ unbind: function( type, fn ) { @@ -1086,7 +1078,7 @@ new function(){ // Clean up after IE to avoid memory leaks if (jQuery.browser.msie) - jQuery(window).bind("unload", function() { + jQuery(window).one("unload", function() { var global = jQuery.event.global; for ( var type in global ) { var els = global[type], i = els.length;