X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fevent.js;h=a2b512ae1b5f5071ba6c90cadd7b2390558d5e49;hb=42f8c3add3e0e4370d4bd6816bf471e07baf34be;hp=283d1e0bfe31dee27263911bca7fdef86cb50644;hpb=fe9333cc792eecf98189f8fd18daf64b64dff049;p=jquery.git diff --git a/src/event.js b/src/event.js index 283d1e0..a2b512a 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. @@ -875,15 +882,15 @@ jQuery.each( ("blur focus load resize scroll unload click dblclick " + // Window isn't included so as not to unbind existing unload events // More info: // - http://isaacschlueter.com/2006/10/msie-memory-leaks/ -/*@cc_on -window.attachEvent("onunload", function() { - for ( var id in jQuery.cache ) { - if ( jQuery.cache[ id ].handle ) { - // Try/Catch is to handle iframes being unloaded, see #4280 - try { - jQuery.event.remove( jQuery.cache[ id ].handle.elem ); - } catch(e) {} +if ( window.attachEvent ) { + window.attachEvent("onunload", function() { + for ( var id in jQuery.cache ) { + if ( jQuery.cache[ id ].handle ) { + // Try/Catch is to handle iframes being unloaded, see #4280 + try { + jQuery.event.remove( jQuery.cache[ id ].handle.elem ); + } catch(e) {} + } } - } -}); -@*/ + }); +}