Thanks to @TheDistantSea for the report!
Fixes gh-1790
Closes gh-1643
},
// Remove all callbacks from the list
empty: function() {
- list = [];
- firingLength = 0;
+ if ( list ) {
+ list = [];
+ firingLength = 0;
+ }
return this;
},
// Have the list do nothing anymore
ok( true, "no stack overflow" );
});
+
+test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function() {
+
+ expect( 1 );
+
+ var cb = jQuery.Callbacks(),
+ fired = false,
+ shot = function() { fired = true; };
+
+ cb.disable();
+ cb.empty();
+ cb.add( shot );
+ cb.fire();
+ ok( !fired, "Disabled callback function didn't fire" );
+});