Skip to content

Commit 6cb2945

Browse files
committed
Rather than declaring empty anonymous functions all around, introduce and use a single empty function. Thanks to Matt Kruse for the suggestion.
1 parent fe6c86d commit 6cb2945

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/ajax.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ jQuery.extend({
384384
// The request was aborted, clear the interval and decrement jQuery.active
385385
if ( !xhr || xhr.readyState === 0 ) {
386386
requestDone = true;
387-
xhr.onreadystatechange = function(){};
387+
xhr.onreadystatechange = jQuery.noop;
388388

389389
// Handle the global AJAX counter
390390
if ( s.global && ! --jQuery.active ) {
@@ -394,7 +394,7 @@ jQuery.extend({
394394
// The transfer is complete and the data is available, or the request timed out
395395
} else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
396396
requestDone = true;
397-
xhr.onreadystatechange = function(){};
397+
xhr.onreadystatechange = jQuery.noop;
398398

399399
status = isTimeout === "timeout" ?
400400
"timeout" :

src/core.js

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)