throw ex;
}
-function adoptValue( value, resolve, reject ) {
+function adoptValue( value, resolve, reject, noValue ) {
var method;
try {
// Other non-thenables
} else {
- // Support: Android 4.0 only
- // Strict mode functions invoked without .call/.apply get global-object context
- resolve.call( undefined, value );
+ // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
+ // * false: [ value ].slice( 0 ) => resolve( value )
+ // * true: [ value ].slice( 1 ) => resolve()
+ resolve.apply( undefined, [ value ].slice( noValue ) );
}
// For Promises/A+, convert exceptions into rejections
// Support: Android 4.0 only
// Strict mode functions invoked without .call/.apply get global-object context
- reject.call( undefined, value );
+ reject.apply( undefined, [ value ] );
}
}
// Single- and empty arguments are adopted like Promise.resolve
if ( remaining <= 1 ) {
- adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject );
+ adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
+ !remaining );
// Use .then() to unwrap secondary thenables (cf. gh-3000)
if ( master.state() === "pending" ||
jQuery.when()
.done( function( resolveValue ) {
- assert.strictEqual( resolveValue, undefined, "Resolved .done with no arguments" );
+ assert.strictEqual( arguments.length, 0, "Resolved .done with no arguments" );
assert.strictEqual( this, defaultContext, "Default .done context with no arguments" );
} )
.then( function( resolveValue ) {
- assert.strictEqual( resolveValue, undefined, "Resolved .then with no arguments" );
+ assert.strictEqual( arguments.length, 0, "Resolved .then with no arguments" );
assert.strictEqual( this, defaultContext, "Default .then context with no arguments" );
} );