From: jaubourg Date: Wed, 27 Feb 2013 15:12:16 +0000 (+0100) Subject: Properly resets firingLength when emptying the list. Fixes #13517 X-Git-Tag: 2.0.0b2~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0618710913f41d7a7f4c095f0edda035e65a887d;p=jquery.git Properly resets firingLength when emptying the list. Fixes #13517 --- diff --git a/src/callbacks.js b/src/callbacks.js index 2bb378047..851333114 100644 --- a/src/callbacks.js +++ b/src/callbacks.js @@ -145,6 +145,7 @@ jQuery.Callbacks = function( options ) { // Remove all callbacks from the list empty: function() { list = []; + firingLength = 0; return this; }, // Have the list do nothing anymore diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js index 9482832db..8962e5810 100644 --- a/test/unit/callbacks.js +++ b/test/unit/callbacks.js @@ -92,6 +92,22 @@ jQuery.each( tests, function( strFlags, resultString ) { cblist.fire("A"); strictEqual( output, "X", "Firing after disabling" ); + // #13517 - Emptying while firing + cblist = jQuery.Callbacks( flags ); + cblist.add( cblist.empty ); + cblist.add( function() { + ok( false, "not emptied" ); + } ); + cblist.fire(); + + // Disabling while firing + cblist = jQuery.Callbacks( flags ); + cblist.add( cblist.disable ); + cblist.add( function() { + ok( false, "not disabled" ); + } ); + cblist.fire(); + // Basic binding and firing (context, arguments) output = "X"; cblist = jQuery.Callbacks( flags );