X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fevent.js;h=b50a1ec4e0249c07c0f42f7cd2be81f890225e66;hb=aa81bb5e458efd25981933c339ac1a0090e6eb0f;hp=018d4d9809929e27bf36224f0721c08251412414;hpb=253e73af5173413b2938f911087d361e42cf0763;p=jquery.git diff --git a/src/event.js b/src/event.js index 018d4d9..b50a1ec 100644 --- a/src/event.js +++ b/src/event.js @@ -37,13 +37,20 @@ jQuery.event = { // Init the element's event structure var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ), - handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function eventHandle() { + handle = jQuery.data( elem, "handle" ), eventHandle; + + if ( !handle ) { + eventHandle = function() { // Handle the second event of a trigger and when // an event is called after a page has unloaded return typeof jQuery !== "undefined" && !jQuery.event.triggered ? jQuery.event.handle.apply( eventHandle.elem, arguments ) : undefined; - }); + }; + + handle = jQuery.data( elem, "handle", eventHandle ); + } + // Add elem as a property of the handle function // This is to prevent a memory leak with non-native // event in IE. @@ -876,10 +883,9 @@ jQuery.each( ("blur focus load resize scroll unload click dblclick " + // More info: // - http://isaacschlueter.com/2006/10/msie-memory-leaks/ /*@cc_on -jQuery( window ).bind( 'unload', function() { +window.attachEvent("onunload", function() { for ( var id in jQuery.cache ) { - // Skip the window - if ( id != 1 && jQuery.cache[ id ].handle ) { + if ( jQuery.cache[ id ].handle ) { // Try/Catch is to handle iframes being unloaded, see #4280 try { jQuery.event.remove( jQuery.cache[ id ].handle.elem );