]> source.dussan.org Git - jquery.git/commitdiff
Revert "Callbacks: Don't abort execution on .lock()"
authorOleg Gaidarenko <markelog@gmail.com>
Fri, 13 Nov 2015 13:38:00 +0000 (16:38 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Fri, 13 Nov 2015 17:04:19 +0000 (20:04 +0300)
This reverts commit 32bf9178cace8c52a31c468a28adde9a4fdc4671.

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

index 58a9a5800735290cddb08beccc7cf2b7d24fa8ac..ce21571eda23b5a1b25e0832766afaf03ad094d5 100644 (file)
@@ -206,7 +206,7 @@ jQuery.Callbacks = function( options ) {
                        lock: function() {
                                stack = undefined;
                                locked = true;
-                               if ( !memory && !firing ) {
+                               if ( !memory ) {
                                        self.disable();
                                }
                                return this;
index c6c379dede88552d4fcac5697fee38e0f29aff98..0bae02a876a29be85306e97d3bc219a2474c57c3 100644 (file)
@@ -65,7 +65,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
 
                                QUnit.test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function( assert ) {
 
-                                       assert.expect( 29 );
+                                       assert.expect( 28 );
 
                                        var cblist,
                                                results = resultString.split( /\s+/ );
@@ -76,20 +76,20 @@ jQuery.each( tests, function( strFlags, resultString ) {
                                        assert.strictEqual( cblist.locked(), false, ".locked() initially false" );
                                        assert.strictEqual( cblist.disabled(), false, ".disabled() initially false" );
                                        assert.strictEqual( cblist.fired(), false, ".fired() initially false" );
-                                       cblist.add( function( str ) {
+                                       cblist.add(function( str ) {
                                                output += str;
-                                       } );
+                                       });
                                        assert.strictEqual( cblist.fired(), false, ".fired() still false after .add" );
                                        cblist.fire( "A" );
                                        assert.strictEqual( output, "XA", "Basic binding and firing" );
                                        assert.strictEqual( cblist.fired(), true, ".fired() detects firing" );
                                        output = "X";
                                        cblist.disable();
-                                       cblist.add( function( str ) {
+                                       cblist.add(function( str ) {
                                                output += str;
-                                       } );
+                                       });
                                        assert.strictEqual( output, "X", "Adding a callback after disabling" );
-                                       cblist.fire( "A" );
+                                       cblist.fire("A");
                                        assert.strictEqual( output, "X", "Firing after disabling" );
                                        assert.strictEqual( cblist.disabled(), true, ".disabled() becomes true" );
                                        assert.strictEqual( cblist.locked(), true, "disabling locks" );
@@ -113,20 +113,20 @@ jQuery.each( tests, function( strFlags, resultString ) {
                                        // Basic binding and firing (context, arguments)
                                        output = "X";
                                        cblist = jQuery.Callbacks( flags );
-                                       cblist.add( function() {
+                                       cblist.add(function() {
                                                assert.equal( this, window, "Basic binding and firing (context)" );
                                                output += Array.prototype.join.call( arguments, "" );
-                                       } );
+                                       });
                                        cblist.fireWith( window, [ "A", "B" ] );
                                        assert.strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
 
                                        // fireWith with no arguments
                                        output = "";
                                        cblist = jQuery.Callbacks( flags );
-                                       cblist.add( function() {
+                                       cblist.add(function() {
                                                assert.equal( this, window, "fireWith with no arguments (context is window)" );
                                                assert.strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
-                                       } );
+                                       });
                                        cblist.fireWith();
 
                                        // Basic binding, removing and firing
@@ -150,34 +150,24 @@ jQuery.each( tests, function( strFlags, resultString ) {
                                        // Locking
                                        output = "X";
                                        cblist = jQuery.Callbacks( flags );
-                                       cblist.add( function( str ) {
+                                       cblist.add(function( str ) {
                                                output += str;
-                                       } );
+                                       });
                                        cblist.lock();
-                                       cblist.add( function( str ) {
+                                       cblist.add(function( str ) {
                                                output += str;
-                                       } );
-                                       cblist.fire( "A" );
-                                       cblist.add( function( str ) {
+                                       });
+                                       cblist.fire("A");
+                                       cblist.add(function( str ) {
                                                output += str;
-                                       } );
+                                       });
                                        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 );
-                                       cblist.add( function() {
+                                       cblist.add(function() {
                                                cblist.add( outputC );
                                                outputA();
                                        }, outputB );
@@ -186,7 +176,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
 
                                        // Add and fire again
                                        output = "X";
-                                       cblist.add( function() {
+                                       cblist.add(function() {
                                                cblist.add( outputC );
                                                outputA();
                                        }, outputB );
@@ -199,23 +189,23 @@ jQuery.each( tests, function( strFlags, resultString ) {
                                        // Multiple fire
                                        output = "X";
                                        cblist = jQuery.Callbacks( flags );
-                                       cblist.add( function( str ) {
+                                       cblist.add(function( str ) {
                                                output += str;
-                                       } );
-                                       cblist.fire( "A" );
+                                       });
+                                       cblist.fire("A");
                                        assert.strictEqual( output, "XA", "Multiple fire (first fire)" );
                                        output = "X";
-                                       cblist.add( function( str ) {
+                                       cblist.add(function( str ) {
                                                output += str;
-                                       } );
+                                       });
                                        assert.strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
                                        output = "X";
-                                       cblist.fire( "B" );
+                                       cblist.fire("B");
                                        assert.strictEqual( output, results.shift(), "Multiple fire (second fire)" );
                                        output = "X";
-                                       cblist.add( function( str ) {
+                                       cblist.add(function( str ) {
                                                output += str;
-                                       } );
+                                       });
                                        assert.strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
 
                                        // Return false