mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Deferred: Rename master to primary
Closes gh-4828
This commit is contained in:
parent
d38528b17a
commit
a32cf6324f
@ -353,8 +353,8 @@ jQuery.extend( {
|
|||||||
resolveContexts = Array( i ),
|
resolveContexts = Array( i ),
|
||||||
resolveValues = slice.call( arguments ),
|
resolveValues = slice.call( arguments ),
|
||||||
|
|
||||||
// the master Deferred
|
// the primary Deferred
|
||||||
master = jQuery.Deferred(),
|
primary = jQuery.Deferred(),
|
||||||
|
|
||||||
// subordinate callback factory
|
// subordinate callback factory
|
||||||
updateFunc = function( i ) {
|
updateFunc = function( i ) {
|
||||||
@ -362,30 +362,30 @@ jQuery.extend( {
|
|||||||
resolveContexts[ i ] = this;
|
resolveContexts[ i ] = this;
|
||||||
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
|
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
|
||||||
if ( !( --remaining ) ) {
|
if ( !( --remaining ) ) {
|
||||||
master.resolveWith( resolveContexts, resolveValues );
|
primary.resolveWith( resolveContexts, resolveValues );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Single- and empty arguments are adopted like Promise.resolve
|
// Single- and empty arguments are adopted like Promise.resolve
|
||||||
if ( remaining <= 1 ) {
|
if ( remaining <= 1 ) {
|
||||||
adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
|
adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
|
||||||
!remaining );
|
!remaining );
|
||||||
|
|
||||||
// Use .then() to unwrap secondary thenables (cf. gh-3000)
|
// Use .then() to unwrap secondary thenables (cf. gh-3000)
|
||||||
if ( master.state() === "pending" ||
|
if ( primary.state() === "pending" ||
|
||||||
typeof( resolveValues[ i ] && resolveValues[ i ].then ) === "function" ) {
|
typeof( resolveValues[ i ] && resolveValues[ i ].then ) === "function" ) {
|
||||||
|
|
||||||
return master.then();
|
return primary.then();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiple arguments are aggregated like Promise.all array elements
|
// Multiple arguments are aggregated like Promise.all array elements
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
|
adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
|
||||||
}
|
}
|
||||||
|
|
||||||
return master.promise();
|
return primary.promise();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user