if ( jQuery.isFunction( fn ) ) {
deferred[ handler ](function() {
returned = fn.apply( this, arguments );
- if ( jQuery.isFunction( returned.promise ) ) {
+ if ( returned && jQuery.isFunction( returned.promise ) ) {
returned.promise().then( newDefer.resolve, newDefer.reject );
} else {
newDefer[ action ]( returned );
test( "jQuery.Deferred.pipe - filtering (done)", function() {
- expect(3);
+ expect(4);
var defer = jQuery.Deferred(),
piped = defer.pipe(function( a, b ) {
jQuery.Deferred().reject().pipe(function() {
ok( false, "pipe should not be called on reject" );
});
+
+ jQuery.Deferred().resolve().pipe( jQuery.noop ).done(function( value ) {
+ strictEqual( value, undefined, "pipe done callback can return undefined/null" );
+ });
});
test( "jQuery.Deferred.pipe - filtering (fail)", function() {
- expect(3);
+ expect(4);
var defer = jQuery.Deferred(),
piped = defer.pipe( null, function( a, b ) {
jQuery.Deferred().resolve().pipe( null, function() {
ok( false, "pipe should not be called on resolve" );
} );
+
+ jQuery.Deferred().reject().pipe( null, jQuery.noop ).fail(function( value ) {
+ strictEqual( value, undefined, "pipe fail callback can return undefined/null" );
+ });
});
test( "jQuery.Deferred.pipe - deferred (done)", function() {