MCPcopy Index your code
hub / github.com/components/jquery / resolve

Function resolve

jquery.js:3213–3336  ·  view source on GitHub ↗
( depth, deferred, handler, special )

Source from the content-addressed store, hash-verified

3211 then: function( onFulfilled, onRejected, onProgress ) {
3212 var maxDepth = 0;
3213 function resolve( depth, deferred, handler, special ) {
3214 return function() {
3215 var that = this,
3216 args = arguments,
3217 mightThrow = function() {
3218 var returned, then;
3219
3220 // Support: Promises/A+ section 2.3.3.3.3
3221 // https://promisesaplus.com/#point-59
3222 // Ignore double-resolution attempts
3223 if ( depth < maxDepth ) {
3224 return;
3225 }
3226
3227 returned = handler.apply( that, args );
3228
3229 // Support: Promises/A+ section 2.3.1
3230 // https://promisesaplus.com/#point-48
3231 if ( returned === deferred.promise() ) {
3232 throw new TypeError( "Thenable self-resolution" );
3233 }
3234
3235 // Support: Promises/A+ sections 2.3.3.1, 3.5
3236 // https://promisesaplus.com/#point-54
3237 // https://promisesaplus.com/#point-75
3238 // Retrieve `then` only once
3239 then = returned &&
3240
3241 // Support: Promises/A+ section 2.3.4
3242 // https://promisesaplus.com/#point-64
3243 // Only check objects and functions for thenability
3244 ( typeof returned === "object" ||
3245 typeof returned === "function" ) &&
3246 returned.then;
3247
3248 // Handle a returned thenable
3249 if ( typeof then === "function" ) {
3250
3251 // Special processors (notify) just wait for resolution
3252 if ( special ) {
3253 then.call(
3254 returned,
3255 resolve( maxDepth, deferred, Identity, special ),
3256 resolve( maxDepth, deferred, Thrower, special )
3257 );
3258
3259 // Normal processors (resolve) also hook into progress
3260 } else {
3261
3262 // ...and disregard older resolution values
3263 maxDepth++;
3264
3265 then.call(
3266 returned,
3267 resolve( maxDepth, deferred, Identity, special ),
3268 resolve( maxDepth, deferred, Thrower, special ),
3269 resolve( maxDepth, deferred, Identity,
3270 deferred.notifyWith )

Callers 2

mightThrowFunction · 0.85
jquery.jsFile · 0.85

Calls 1

mightThrowFunction · 0.85

Tested by

no test coverage detected