From: Oleg Gaidarenko Date: Tue, 22 Dec 2015 14:20:29 +0000 (+0300) Subject: Revert "Callbacks: Don't abort execution on .lock()" X-Git-Tag: 1.12.0~48 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=885a0ccdd3dff21dc94d9cc905c326f0d0454838;p=jquery.git Revert "Callbacks: Don't abort execution on .lock()" This reverts commit fc7477f4927100f23f83c22b5142a42d1eac8502. --- diff --git a/src/callbacks.js b/src/callbacks.js index b032c8f1c..651656964 100644 --- a/src/callbacks.js +++ b/src/callbacks.js @@ -190,9 +190,9 @@ jQuery.Callbacks = function( options ) { // Also disable .add unless we have memory (since it would have no effect) // Abort any pending executions lock: function() { - locked = queue = []; - if ( !memory && !firing ) { - list = memory = ""; + locked = true; + if ( !memory ) { + self.disable(); } return this; }, diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js index c6c379ded..eec58a80d 100644 --- a/test/unit/callbacks.js +++ b/test/unit/callbacks.js @@ -65,7 +65,7 @@ jQuery.each( tests, function( strFlags, resultString ) { QUnit.test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function( assert ) { - assert.expect( 29 ); + expect( 28 ); var cblist, results = resultString.split( /\s+/ ); @@ -94,7 +94,7 @@ jQuery.each( tests, function( strFlags, resultString ) { assert.strictEqual( cblist.disabled(), true, ".disabled() becomes true" ); assert.strictEqual( cblist.locked(), true, "disabling locks" ); - // Emptying while firing (#13517) + // #13517 - Emptying while firing cblist = jQuery.Callbacks( flags ); cblist.add( cblist.empty ); cblist.add( function() { @@ -164,16 +164,6 @@ jQuery.each( tests, function( strFlags, resultString ) { assert.strictEqual( output, "X", "Lock early" ); assert.strictEqual( cblist.locked(), true, "Locking reflected in accessor" ); - // Locking while firing (gh-1990) - output = "X"; - cblist = jQuery.Callbacks( flags ); - cblist.add( cblist.lock ); - cblist.add( function( str ) { - output += str; - } ); - cblist.fire( "A" ); - assert.strictEqual( output, "XA", "Locking doesn't abort execution (gh-1990)" ); - // Ordering output = "X"; cblist = jQuery.Callbacks( flags ); @@ -340,8 +330,8 @@ QUnit.test( "jQuery.Callbacks.has", function( assert ) { cb.add( getA ); assert.strictEqual( cb.has(), true, "Check if unique list has callback function(s) attached" ); cb.lock(); - assert.strictEqual( cb.has(), false, "locked() list is empty and returns false" ); -} ); + strictEqual( cb.has(), false, "locked() list is empty and returns false" ); +}); QUnit.test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow", function( assert ) {