Commit 6cb29458 authored by jeresig's avatar jeresig

Rather than declaring empty anonymous functions all around, introduce and use...

Rather than declaring empty anonymous functions all around, introduce and use a single empty function. Thanks to Matt Kruse for the suggestion.
parent fe6c86d5
...@@ -384,7 +384,7 @@ jQuery.extend({ ...@@ -384,7 +384,7 @@ jQuery.extend({
// The request was aborted, clear the interval and decrement jQuery.active // The request was aborted, clear the interval and decrement jQuery.active
if ( !xhr || xhr.readyState === 0 ) { if ( !xhr || xhr.readyState === 0 ) {
requestDone = true; requestDone = true;
xhr.onreadystatechange = function(){}; xhr.onreadystatechange = jQuery.noop;
// Handle the global AJAX counter // Handle the global AJAX counter
if ( s.global && ! --jQuery.active ) { if ( s.global && ! --jQuery.active ) {
...@@ -394,7 +394,7 @@ jQuery.extend({ ...@@ -394,7 +394,7 @@ jQuery.extend({
// The transfer is complete and the data is available, or the request timed out // The transfer is complete and the data is available, or the request timed out
} else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) { } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
requestDone = true; requestDone = true;
xhr.onreadystatechange = function(){}; xhr.onreadystatechange = jQuery.noop;
status = isTimeout === "timeout" ? status = isTimeout === "timeout" ?
"timeout" : "timeout" :
......
...@@ -464,6 +464,8 @@ jQuery.extend({ ...@@ -464,6 +464,8 @@ jQuery.extend({
return true; return true;
}, },
noop: function() {},
// Evalulates a script in a global context // Evalulates a script in a global context
globalEval: function( data ) { globalEval: function( data ) {
if ( data && rnotwhite.test(data) ) { if ( data && rnotwhite.test(data) ) {
......
...@@ -427,7 +427,7 @@ jQuery.event = { ...@@ -427,7 +427,7 @@ jQuery.event = {
ready: { ready: {
// Make sure the ready event is setup // Make sure the ready event is setup
setup: jQuery.bindReady, setup: jQuery.bindReady,
teardown: function() {} teardown: jQuery.noop
}, },
live: { live: {
......
...@@ -121,7 +121,7 @@ jQuery.offset = { ...@@ -121,7 +121,7 @@ jQuery.offset = {
body.removeChild( container ); body.removeChild( container );
body = container = innerDiv = checkDiv = table = td = null; body = container = innerDiv = checkDiv = table = td = null;
jQuery.offset.initialize = function() {}; jQuery.offset.initialize = jQuery.noop;
}, },
bodyOffset: function( body ) { bodyOffset: function( body ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment