mirror of
https://github.com/jquery/jquery.git
synced 2026-02-03 07:05:09 -05:00
How about we save 62 bytes? Also ensure that the arguments array given to fireWith is copied internally.
This commit is contained in:
@@ -209,15 +209,29 @@ test( "jQuery.Callbacks( options ) - options are copied", function() {
|
||||
expect( 1 );
|
||||
|
||||
var options = {
|
||||
memory: true
|
||||
unique: true
|
||||
},
|
||||
cb = jQuery.Callbacks( options );
|
||||
cb = jQuery.Callbacks( options ),
|
||||
count = 0,
|
||||
fn = function() {
|
||||
ok( !( count++ ), "called once" );
|
||||
};
|
||||
options.unique = false;
|
||||
cb.add( fn, fn );
|
||||
cb.fire();
|
||||
});
|
||||
|
||||
options.memory = false;
|
||||
test( "jQuery.Callbacks.fireWith - arguments are copied", function() {
|
||||
|
||||
cb.fire( "hello" );
|
||||
expect( 1 );
|
||||
|
||||
var cb = jQuery.Callbacks( "memory" ),
|
||||
args = [ "hello" ];
|
||||
|
||||
cb.fireWith( null, args );
|
||||
args[ 0 ] = "world";
|
||||
|
||||
cb.add(function( hello ) {
|
||||
strictEqual( hello, "hello", "options are copied internally" );
|
||||
strictEqual( hello, "hello", "arguments are copied internally" );
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user