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
(cherry picked from a32cf6324f
)
This commit is contained in:
parent
7298e04fae
commit
15b62a2eb5
@ -359,8 +359,8 @@ jQuery.extend( {
|
||||
resolveContexts = Array( i ),
|
||||
resolveValues = slice.call( arguments ),
|
||||
|
||||
// the master Deferred
|
||||
master = jQuery.Deferred(),
|
||||
// the primary Deferred
|
||||
primary = jQuery.Deferred(),
|
||||
|
||||
// subordinate callback factory
|
||||
updateFunc = function( i ) {
|
||||
@ -368,30 +368,30 @@ jQuery.extend( {
|
||||
resolveContexts[ i ] = this;
|
||||
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
|
||||
if ( !( --remaining ) ) {
|
||||
master.resolveWith( resolveContexts, resolveValues );
|
||||
primary.resolveWith( resolveContexts, resolveValues );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Single- and empty arguments are adopted like Promise.resolve
|
||||
if ( remaining <= 1 ) {
|
||||
adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
|
||||
adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
|
||||
!remaining );
|
||||
|
||||
// Use .then() to unwrap secondary thenables (cf. gh-3000)
|
||||
if ( master.state() === "pending" ||
|
||||
if ( primary.state() === "pending" ||
|
||||
isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
|
||||
|
||||
return master.then();
|
||||
return primary.then();
|
||||
}
|
||||
}
|
||||
|
||||
// Multiple arguments are aggregated like Promise.all array elements
|
||||
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