]> source.dussan.org Git - jquery.git/commitdiff
Properly resets firingLength when emptying the list. Fixes #13517
authorjaubourg <j@ubourg.net>
Wed, 27 Feb 2013 15:12:16 +0000 (16:12 +0100)
committerjaubourg <j@ubourg.net>
Wed, 27 Feb 2013 15:12:16 +0000 (16:12 +0100)
src/callbacks.js
test/unit/callbacks.js

index d94f0b329e21deaa7a21e28c742a943ff02c3918..5ca7cea25a04a75311dec7f29000f4548128caf2 100644 (file)
@@ -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
index 9482832db23950a4ccba40577a8c32a266df93d3..8962e5810a6e95dad6cf44f49c7a4812c512189f 100644 (file)
@@ -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 );