From a14a31727feed23c4ba4e4948700b7719ce219aa Mon Sep 17 00:00:00 2001 From: jaubourg Date: Wed, 27 Feb 2013 16:12:16 +0100 Subject: [PATCH] Properly resets firingLength when emptying the list. Fixes #13517 --- src/callbacks.js | 1 + test/unit/callbacks.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/callbacks.js b/src/callbacks.js index d94f0b329..5ca7cea25 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 ); -- 2.39.5