From 4632e55870a00a70e737a862cdb0820278cec0fe Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Sun, 3 May 2015 13:39:33 +0300 Subject: [PATCH] Ajax: remove "onunload" event handler Remove hack for IE lost connections, update for it was released by Microsoft at November 12, 2013. See https://support.microsoft.com/en-us/kb/2905733 Ref trac-5280 Ref gh-2047 Ref a117dd05f638a078c21dc57f19966f4ae81f98f0 --- src/ajax/xhr.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js index ac5bc81d9..9c204a851 100644 --- a/src/ajax/xhr.js +++ b/src/ajax/xhr.js @@ -26,20 +26,7 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ? // For all other browsers, use the standard XMLHttpRequest object createStandardXHR; -var xhrId = 0, - xhrCallbacks = {}, - xhrSupported = jQuery.ajaxSettings.xhr(); - -// Support: IE<10 -// Open requests must be manually aborted on unload (#5280) -// See https://support.microsoft.com/kb/2856746 for more info -if ( window.attachEvent ) { - window.attachEvent( "onunload", function() { - for ( var key in xhrCallbacks ) { - xhrCallbacks[ key ]( undefined, true ); - } - }); -} +var xhrSupported = jQuery.ajaxSettings.xhr(); // Determine support properties support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); @@ -57,8 +44,7 @@ if ( xhrSupported ) { return { send: function( headers, complete ) { var i, - xhr = options.xhr(), - id = ++xhrId; + xhr = options.xhr(); // Open the socket xhr.open( @@ -115,7 +101,6 @@ if ( xhrSupported ) { // Was never called and is aborted or complete if ( callback && ( isAbort || xhr.readyState === 4 ) ) { // Clean up - delete xhrCallbacks[ id ]; callback = undefined; xhr.onreadystatechange = jQuery.noop; @@ -169,7 +154,7 @@ if ( xhrSupported ) { callback(); } else { // Add to the list of active xhr callbacks - xhr.onreadystatechange = xhrCallbacks[ id ] = callback; + xhr.onreadystatechange = callback; } }, -- 2.39.5