From 6cb2945837ccca55204191a8e7a70b2b2486c28e Mon Sep 17 00:00:00 2001 From: jeresig Date: Thu, 31 Dec 2009 09:50:49 -0500 Subject: [PATCH] Rather than declaring empty anonymous functions all around, introduce and use a single empty function. Thanks to Matt Kruse for the suggestion. --- src/ajax.js | 4 ++-- src/core.js | 2 ++ src/event.js | 2 +- src/offset.js | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index 2249dc68..37fb75b5 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -384,7 +384,7 @@ jQuery.extend({ // The request was aborted, clear the interval and decrement jQuery.active if ( !xhr || xhr.readyState === 0 ) { requestDone = true; - xhr.onreadystatechange = function(){}; + xhr.onreadystatechange = jQuery.noop; // Handle the global AJAX counter if ( s.global && ! --jQuery.active ) { @@ -394,7 +394,7 @@ jQuery.extend({ // The transfer is complete and the data is available, or the request timed out } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) { requestDone = true; - xhr.onreadystatechange = function(){}; + xhr.onreadystatechange = jQuery.noop; status = isTimeout === "timeout" ? "timeout" : diff --git a/src/core.js b/src/core.js index 944e8a9b..93f04ec7 100644 --- a/src/core.js +++ b/src/core.js @@ -464,6 +464,8 @@ jQuery.extend({ return true; }, + noop: function() {}, + // Evalulates a script in a global context globalEval: function( data ) { if ( data && rnotwhite.test(data) ) { diff --git a/src/event.js b/src/event.js index 79a6b952..0345b0c1 100644 --- a/src/event.js +++ b/src/event.js @@ -427,7 +427,7 @@ jQuery.event = { ready: { // Make sure the ready event is setup setup: jQuery.bindReady, - teardown: function() {} + teardown: jQuery.noop }, live: { diff --git a/src/offset.js b/src/offset.js index 7ae9cb90..d12921df 100644 --- a/src/offset.js +++ b/src/offset.js @@ -121,7 +121,7 @@ jQuery.offset = { body.removeChild( container ); body = container = innerDiv = checkDiv = table = td = null; - jQuery.offset.initialize = function() {}; + jQuery.offset.initialize = jQuery.noop; }, bodyOffset: function( body ) {