diff options
author | jaubourg <j@ubourg.net> | 2012-04-28 22:54:13 +0200 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2012-04-28 22:54:13 +0200 |
commit | 5fc8d9e454a7abdf77a7de14aac7a94af276709f (patch) | |
tree | f87c3f9911c750efcbbc3f6dc08c133d33dd74d9 /src/callbacks.js | |
parent | 6ad53c33d8fb4fa2f8adeef3d756875e4832f8a4 (diff) | |
download | jquery-5fc8d9e454a7abdf77a7de14aac7a94af276709f.tar.gz jquery-5fc8d9e454a7abdf77a7de14aac7a94af276709f.zip |
Simplifies the way the internal memory storage is handled.
Diffstat (limited to 'src/callbacks.js')
-rw-r--r-- | src/callbacks.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/callbacks.js b/src/callbacks.js index b3b1c8a69..5516d551f 100644 --- a/src/callbacks.js +++ b/src/callbacks.js @@ -60,7 +60,7 @@ jQuery.Callbacks = function( options ) { firingIndex, // Fire callbacks fire = function( data ) { - memory = !options.memory || data; + memory = options.memory && data; fired = true; firingIndex = firingStart || 0; firingStart = 0; @@ -68,7 +68,7 @@ jQuery.Callbacks = function( options ) { firing = true; for ( ; list && firingIndex < firingLength; firingIndex++ ) { if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { - memory = true; // Mark as halted + memory = false; // To prevent further calls using add break; } } @@ -78,10 +78,10 @@ jQuery.Callbacks = function( options ) { if ( stack.length ) { fire( stack.shift() ); } - } else if ( memory === true ) { - self.disable(); - } else { + } else if ( memory ) { list = []; + } else { + self.disable(); } } }, @@ -107,9 +107,8 @@ jQuery.Callbacks = function( options ) { if ( firing ) { firingLength = list.length; // With memory, if we're not firing then - // we should call right away, unless previous - // firing was halted (stopOnFalse) - } else if ( memory && memory !== true ) { + // we should call right away + } else if ( memory ) { firingStart = start; fire( memory ); } @@ -158,7 +157,7 @@ jQuery.Callbacks = function( options ) { // Lock the list in its current state lock: function() { stack = undefined; - if ( !memory || memory === true ) { + if ( !memory ) { self.disable(); } return this; |