aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaubourg <j@ubourg.net>2013-02-27 16:12:16 +0100
committerjaubourg <j@ubourg.net>2013-02-27 16:15:32 +0100
commit0618710913f41d7a7f4c095f0edda035e65a887d (patch)
tree89ace9aa0aed7577356572c33b43de6e9956252f
parent1b6be73721270225fea8a182f4a57ae44f5e6405 (diff)
downloadjquery-0618710913f41d7a7f4c095f0edda035e65a887d.tar.gz
jquery-0618710913f41d7a7f4c095f0edda035e65a887d.zip
Properly resets firingLength when emptying the list. Fixes #13517
-rw-r--r--src/callbacks.js1
-rw-r--r--test/unit/callbacks.js16
2 files changed, 17 insertions, 0 deletions
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 );