Skip to content

Commit 40ce7f9

Browse files
committed
Merge branch 'bug-5735'
2 parents 6cf981e + 6cb2945 commit 40ce7f9

File tree

4 files changed

+20
-31
lines changed

4 files changed

+20
-31
lines changed

src/ajax.js

+16-29
Original file line numberDiff line numberDiff line change
@@ -380,29 +380,21 @@ jQuery.extend({
380380
}
381381

382382
// Wait for a response to come back
383-
var onreadystatechange = function( isTimeout ) {
383+
var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
384384
// The request was aborted, clear the interval and decrement jQuery.active
385385
if ( !xhr || xhr.readyState === 0 ) {
386-
if ( ival ) {
387-
// clear poll interval
388-
clearInterval( ival );
389-
ival = null;
390-
391-
// Handle the global AJAX counter
392-
if ( s.global && ! --jQuery.active ) {
393-
jQuery.event.trigger( "ajaxStop" );
394-
}
386+
requestDone = true;
387+
xhr.onreadystatechange = jQuery.noop;
388+
389+
// Handle the global AJAX counter
390+
if ( s.global && ! --jQuery.active ) {
391+
jQuery.event.trigger( "ajaxStop" );
395392
}
396393

397394
// The transfer is complete and the data is available, or the request timed out
398395
} else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
399396
requestDone = true;
400-
401-
// clear poll interval
402-
if (ival) {
403-
clearInterval(ival);
404-
ival = null;
405-
}
397+
xhr.onreadystatechange = jQuery.noop;
406398

407399
status = isTimeout === "timeout" ?
408400
"timeout" :
@@ -446,19 +438,14 @@ jQuery.extend({
446438
}
447439
};
448440

449-
if ( s.async ) {
450-
// don't attach the handler to the request, just poll it instead
451-
var ival = setInterval(onreadystatechange, 13);
452-
453-
// Timeout checker
454-
if ( s.timeout > 0 ) {
455-
setTimeout(function() {
456-
// Check to see if the request is still happening
457-
if ( xhr && !requestDone ) {
458-
onreadystatechange( "timeout" );
459-
}
460-
}, s.timeout);
461-
}
441+
// Timeout checker
442+
if ( s.async && s.timeout > 0 ) {
443+
setTimeout(function() {
444+
// Check to see if the request is still happening
445+
if ( xhr && !requestDone ) {
446+
onreadystatechange( "timeout" );
447+
}
448+
}, s.timeout);
462449
}
463450

464451
// Send the data

src/core.js

+2
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ jQuery.extend({
464464
return true;
465465
},
466466

467+
noop: function() {},
468+
467469
// Evalulates a script in a global context
468470
globalEval: function( data ) {
469471
if ( data && rnotwhite.test(data) ) {

src/event.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ jQuery.event = {
427427
ready: {
428428
// Make sure the ready event is setup
429429
setup: jQuery.bindReady,
430-
teardown: function() {}
430+
teardown: jQuery.noop
431431
},
432432

433433
live: {

src/offset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jQuery.offset = {
121121

122122
body.removeChild( container );
123123
body = container = innerDiv = checkDiv = table = td = null;
124-
jQuery.offset.initialize = function() {};
124+
jQuery.offset.initialize = jQuery.noop;
125125
},
126126

127127
bodyOffset: function( body ) {

0 commit comments

Comments
 (0)