]> source.dussan.org Git - jquery.git/commitdiff
Revert "Callbacks: Don't abort execution on .lock()"
authorOleg Gaidarenko <markelog@gmail.com>
Tue, 22 Dec 2015 14:20:29 +0000 (17:20 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Tue, 22 Dec 2015 14:20:29 +0000 (17:20 +0300)
This reverts commit fc7477f4927100f23f83c22b5142a42d1eac8502.

src/callbacks.js
test/unit/callbacks.js

index b032c8f1ce0b28cbdb2b2c4ae9de44e2251aacd9..6516569640cf77258c8d449f5897668a1e94245b 100644 (file)
@@ -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;
                        },
index c6c379dede88552d4fcac5697fee38e0f29aff98..eec58a80d482eec2fcbb83455e1405ab9ce74817 100644 (file)
@@ -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 ) {