diff options
author | jaubourg <j@ubourg.net> | 2013-02-27 16:12:16 +0100 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2013-02-27 16:15:32 +0100 |
commit | 0618710913f41d7a7f4c095f0edda035e65a887d (patch) | |
tree | 89ace9aa0aed7577356572c33b43de6e9956252f | |
parent | 1b6be73721270225fea8a182f4a57ae44f5e6405 (diff) | |
download | jquery-0618710913f41d7a7f4c095f0edda035e65a887d.tar.gz jquery-0618710913f41d7a7f4c095f0edda035e65a887d.zip |
Properly resets firingLength when emptying the list. Fixes #13517
-rw-r--r-- | src/callbacks.js | 1 | ||||
-rw-r--r-- | test/unit/callbacks.js | 16 |
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 ); |