Renamed "complete" to "done" in order to avoid conflicts with jXHR.complete.

This commit is contained in:
jaubourg 2011-01-06 01:26:06 +01:00
parent 47e4cc1a0f
commit 1ca82ccd94
3 changed files with 21 additions and 21 deletions

View File

@ -496,9 +496,9 @@ jQuery.extend({
// Attach deferreds // Attach deferreds
deferred.promise( jXHR ); deferred.promise( jXHR );
jXHR.success = jXHR.complete; jXHR.success = jXHR.done;
jXHR.error = jXHR.fail; jXHR.error = jXHR.fail;
jXHR.complete = completeDeferred.complete; jXHR.complete = completeDeferred.done;
// Remove hash character (#7531: and string promotion) // Remove hash character (#7531: and string promotion)
s.url = ( "" + s.url ).replace( rhash , "" ); s.url = ( "" + s.url ).replace( rhash , "" );

View File

@ -258,7 +258,7 @@ jQuery.fn = jQuery.prototype = {
jQuery.bindReady(); jQuery.bindReady();
// Change ready & apply // Change ready & apply
return ( jQuery.fn.ready = readyList.complete ).apply( this , arguments ); return ( jQuery.fn.ready = readyList.done ).apply( this , arguments );
}, },
eq: function( i ) { eq: function( i ) {
@ -815,8 +815,8 @@ jQuery.extend({
// the deferred itself // the deferred itself
deferred = { deferred = {
// complete( f1, f2, ...) // done( f1, f2, ...)
complete: function () { done: function () {
if ( ! cancelled ) { if ( ! cancelled ) {
@ -836,7 +836,7 @@ jQuery.extend({
elem = args[ i ]; elem = args[ i ];
type = jQuery.type( elem ); type = jQuery.type( elem );
if ( type === "array" ) { if ( type === "array" ) {
deferred.complete.apply( deferred , elem ); deferred.done.apply( deferred , elem );
} else if ( type === "function" ) { } else if ( type === "function" ) {
callbacks.push( elem ); callbacks.push( elem );
} }
@ -901,11 +901,11 @@ jQuery.extend({
// Add errorDeferred methods and redefine cancel // Add errorDeferred methods and redefine cancel
jQuery.extend( deferred , { jQuery.extend( deferred , {
then: function( completeCallbacks , failCallbacks ) { then: function( doneCallbacks , failCallbacks ) {
deferred.complete( completeCallbacks ).fail( failCallbacks ); deferred.done( doneCallbacks ).fail( failCallbacks );
return this; return this;
}, },
fail: failDeferred.complete, fail: failDeferred.done,
fireReject: failDeferred.fire, fireReject: failDeferred.fire,
reject: failDeferred.resolve, reject: failDeferred.resolve,
isRejected: failDeferred.isResolved, isRejected: failDeferred.isResolved,
@ -913,7 +913,7 @@ jQuery.extend({
// If obj is provided, the promise aspect is added to the object // If obj is provided, the promise aspect is added to the object
promise: function( obj ) { promise: function( obj ) {
obj = obj || {}; obj = obj || {};
jQuery.each( "then complete fail isResolved isRejected".split( " " ) , function( _ , method ) { jQuery.each( "then done fail isResolved isRejected".split( " " ) , function( _ , method ) {
obj[ method ] = deferred[ method ]; obj[ method ] = deferred[ method ];
}); });
obj.promise = function() { obj.promise = function() {

View File

@ -915,7 +915,7 @@ test("jQuery._Deferred()", function() {
test = false; test = false;
deferred.complete( function( value ) { deferred.done( function( value ) {
equals( value , "value" , "Test pre-resolve callback" ); equals( value , "value" , "Test pre-resolve callback" );
test = true; test = true;
} ); } );
@ -926,7 +926,7 @@ test("jQuery._Deferred()", function() {
test = false; test = false;
deferred.complete( function( value ) { deferred.done( function( value ) {
equals( value , "value" , "Test post-resolve callback" ); equals( value , "value" , "Test post-resolve callback" );
test = true; test = true;
} ); } );
@ -937,7 +937,7 @@ test("jQuery._Deferred()", function() {
test = true; test = true;
deferred.complete( function() { deferred.done( function() {
ok( false , "Cancel was ignored" ); ok( false , "Cancel was ignored" );
test = false; test = false;
} ); } );
@ -947,18 +947,18 @@ test("jQuery._Deferred()", function() {
deferred = jQuery._Deferred().resolve(); deferred = jQuery._Deferred().resolve();
try { try {
deferred.complete( function() { deferred.done( function() {
throw "Error"; throw "Error";
} , function() { } , function() {
ok( true , "Test deferred do not cancel on exception" ); ok( true , "Test deferred do not cancel on exception" );
} ); } );
} catch( e ) { } catch( e ) {
strictEqual( e , "Error" , "Test deferred propagates exceptions"); strictEqual( e , "Error" , "Test deferred propagates exceptions");
deferred.complete(); deferred.done();
} }
test = ""; test = "";
deferred = jQuery._Deferred().complete( function() { deferred = jQuery._Deferred().done( function() {
test += "A"; test += "A";
@ -968,13 +968,13 @@ test("jQuery._Deferred()", function() {
} ).resolve(); } ).resolve();
strictEqual( test , "AB" , "Test multiple complete parameters" ); strictEqual( test , "AB" , "Test multiple done parameters" );
test = ""; test = "";
deferred.complete( function() { deferred.done( function() {
deferred.complete( function() { deferred.done( function() {
test += "C"; test += "C";
@ -987,11 +987,11 @@ test("jQuery._Deferred()", function() {
test += "B"; test += "B";
} ); } );
strictEqual( test , "ABC" , "Test complete callbacks order" ); strictEqual( test , "ABC" , "Test done callbacks order" );
deferred = jQuery._Deferred(); deferred = jQuery._Deferred();
deferred.fire( jQuery , [ document ] ).complete( function( doc ) { deferred.fire( jQuery , [ document ] ).done( function( doc ) {
ok( this === jQuery && arguments.length === 1 && doc === document , "Test fire context & args" ); ok( this === jQuery && arguments.length === 1 && doc === document , "Test fire context & args" );
}); });
}); });