From 951c4eafa520d1ad51d243ca6dd3f1675336714e Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Wed, 11 Nov 2015 19:07:21 +0300 Subject: [PATCH] Revert "Deferred: add .catch handler" This reverts commit 84ccf2606c6b97d5875774bf774f9f2aae950ae7. --- src/deferred.js | 3 --- test/unit/deferred.js | 36 ------------------------------------ 2 files changed, 39 deletions(-) diff --git a/src/deferred.js b/src/deferred.js index e1af425d4..6c85dd6fd 100644 --- a/src/deferred.js +++ b/src/deferred.js @@ -34,9 +34,6 @@ jQuery.extend( { deferred.done( arguments ).fail( arguments ); return this; }, - "catch": function( fn ) { - return promise.then( null, fn ); - }, // Keep pipe for back-compat pipe: function( /* fnDone, fnFail, fnProgress */ ) { diff --git a/test/unit/deferred.js b/test/unit/deferred.js index 2277df190..a71273727 100644 --- a/test/unit/deferred.js +++ b/test/unit/deferred.js @@ -166,42 +166,6 @@ QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) { } ); } ); -QUnit.test( "jQuery.Deferred.catch", function( assert ) { - assert.expect( 4 ); - - var value1, value2, value3, - defer = jQuery.Deferred(), - piped = defer[ "catch" ]( function( a, b ) { - return a * b; - } ), - done = jQuery.map( new Array( 3 ), function() { return assert.async(); } ); - - piped.done( function( result ) { - value3 = result; - } ); - - defer.fail( function( a, b ) { - value1 = a; - value2 = b; - } ); - - defer.reject( 2, 3 )[ "catch" ]( function() { - assert.strictEqual( value1, 2, "first reject value ok" ); - assert.strictEqual( value2, 3, "second reject value ok" ); - assert.strictEqual( value3, 6, "result of filter ok" ); - done.pop().call(); - } ); - - jQuery.Deferred().resolve()[ "catch" ]( function() { - assert.ok( false, "then should not be called on resolve" ); - } ).then( done.pop() ); - - jQuery.Deferred().reject()[ "catch" ]( jQuery.noop ).done( function( value ) { - assert.strictEqual( value, undefined, "then fail callback can return undefined/null" ); - done.pop().call(); - } ); -} ); - QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) { assert.expect( 4 ); -- 2.39.5