]> 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:15:32 +0000 (16:15 +0100)
src/callbacks.js
test/unit/callbacks.js

index 2bb378047804002991ef484d45917cbb19a931e2..85133311490aee95407d54b5ee959e7733367f8a 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 );