Commit 5fc8d9e4 authored by jaubourg's avatar jaubourg

Simplifies the way the internal memory storage is handled.

parent 6ad53c33
...@@ -60,7 +60,7 @@ jQuery.Callbacks = function( options ) { ...@@ -60,7 +60,7 @@ jQuery.Callbacks = function( options ) {
firingIndex, firingIndex,
// Fire callbacks // Fire callbacks
fire = function( data ) { fire = function( data ) {
memory = !options.memory || data; memory = options.memory && data;
fired = true; fired = true;
firingIndex = firingStart || 0; firingIndex = firingStart || 0;
firingStart = 0; firingStart = 0;
...@@ -68,7 +68,7 @@ jQuery.Callbacks = function( options ) { ...@@ -68,7 +68,7 @@ jQuery.Callbacks = function( options ) {
firing = true; firing = true;
for ( ; list && firingIndex < firingLength; firingIndex++ ) { for ( ; list && firingIndex < firingLength; firingIndex++ ) {
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { 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; break;
} }
} }
...@@ -78,10 +78,10 @@ jQuery.Callbacks = function( options ) { ...@@ -78,10 +78,10 @@ jQuery.Callbacks = function( options ) {
if ( stack.length ) { if ( stack.length ) {
fire( stack.shift() ); fire( stack.shift() );
} }
} else if ( memory === true ) { } else if ( memory ) {
self.disable();
} else {
list = []; list = [];
} else {
self.disable();
} }
} }
}, },
...@@ -107,9 +107,8 @@ jQuery.Callbacks = function( options ) { ...@@ -107,9 +107,8 @@ jQuery.Callbacks = function( options ) {
if ( firing ) { if ( firing ) {
firingLength = list.length; firingLength = list.length;
// With memory, if we're not firing then // With memory, if we're not firing then
// we should call right away, unless previous // we should call right away
// firing was halted (stopOnFalse) } else if ( memory ) {
} else if ( memory && memory !== true ) {
firingStart = start; firingStart = start;
fire( memory ); fire( memory );
} }
...@@ -158,7 +157,7 @@ jQuery.Callbacks = function( options ) { ...@@ -158,7 +157,7 @@ jQuery.Callbacks = function( options ) {
// Lock the list in its current state // Lock the list in its current state
lock: function() { lock: function() {
stack = undefined; stack = undefined;
if ( !memory || memory === true ) { if ( !memory ) {
self.disable(); self.disable();
} }
return this; return this;
......
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