Commit 245f5a24 authored by jaubourg's avatar jaubourg

Regression: makes sure that all instances of a callback are removed. Unit test added.

parent 97210d4e
......@@ -119,8 +119,8 @@ jQuery.Callbacks = function( options ) {
// Remove a callback from the list
remove: function() {
if ( list ) {
jQuery.each( arguments, function( index, arg ) {
if ( ( index = jQuery.inArray( arg, list ) ) > -1 ) {
jQuery.each( arguments, function( _, arg, index ) {
while( ( index = jQuery.inArray( arg, list, index || 0 ) ) > -1 ) {
list.splice( index, 1 );
// Handle firing indexes
if ( firing ) {
......
......@@ -235,3 +235,18 @@ test( "jQuery.Callbacks.fireWith - arguments are copied", function() {
strictEqual( hello, "hello", "arguments are copied internally" );
});
});
test( "jQuery.Callbacks.remove - should remove all instances", function() {
expect( 1 );
var cb = jQuery.Callbacks();
function fn() {
ok( false, "function wasn't removed" );
}
cb.add( fn, fn, function() {
ok( true, "end of test" );
}).remove( fn ).fire();
});
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