Skip to content

Commit

Permalink
Simplifies the way the internal memory storage is handled.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaubourg committed Apr 28, 2012
1 parent 6ad53c3 commit 5fc8d9e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ 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;
firingLength = list.length;
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;
}
}
Expand All @@ -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();
}
}
},
Expand All @@ -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 );
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5fc8d9e

Please sign in to comment.