…es the slice method of the args array in fireWith rather than a quite slow jQuery.merge.
- Loading branch information
There are no files selected for viewing
@@ -94,12 +94,11 @@ jQuery.Callbacks = function( options ) { | ||
var start = list.length; | ||
(function add( args ) { | ||
jQuery.each( args, function( _, arg ) { | ||
var type; | ||
if ( ( type = jQuery.type(arg) ) === "array" ) { | ||
if ( jQuery.isFunction( arg ) && ( !options.unique || !self.has( arg ) ) ) { | ||
list.push( arg ); | ||
} else if ( arg && arg.length ) { | ||
// Inspect recursively | ||
This comment has been minimized.
This comment has been minimized.
jaubourg
Author
Member
|
||
add( arg ); | ||
} else if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) { | ||
list.push( arg ); | ||
} | ||
}); | ||
})( arguments ); | ||
@@ -121,7 +120,7 @@ jQuery.Callbacks = function( options ) { | ||
remove: function() { | ||
if ( list ) { | ||
jQuery.each( arguments, function( _, arg ) { | ||
var index = 0; | ||
var index; | ||
while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { | ||
list.splice( index, 1 ); | ||
// Handle firing indexes | ||
@@ -170,7 +169,8 @@ jQuery.Callbacks = function( options ) { | ||
}, | ||
// Call all callbacks with the given context and arguments | ||
fireWith: function( context, args ) { | ||
args = [ context, jQuery.merge( [], args || [] ) ]; | ||
args = args || []; | ||
args = [ context, args.slice ? args.slice() : args ]; | ||
This comment has been minimized.
gibson042
Member
|
||
if ( list && ( !fired || stack ) ) { | ||
if ( firing ) { | ||
stack.push( args ); | ||
This treats every Function as an array like object (and String too but that was fixed later) and loops through prototype, so if something like say Modernizr pollyfills bind, it will add bind to the callbacks.