()
| 3754 | var that = this, |
| 3755 | args = arguments, |
| 3756 | mightThrow = function() { |
| 3757 | var returned, then; |
| 3758 | |
| 3759 | // Support: Promises/A+ section 2.3.3.3.3 |
| 3760 | // https://promisesaplus.com/#point-59 |
| 3761 | // Ignore double-resolution attempts |
| 3762 | if ( depth < maxDepth ) { |
| 3763 | return; |
| 3764 | } |
| 3765 | |
| 3766 | returned = handler.apply( that, args ); |
| 3767 | |
| 3768 | // Support: Promises/A+ section 2.3.1 |
| 3769 | // https://promisesaplus.com/#point-48 |
| 3770 | if ( returned === deferred.promise() ) { |
| 3771 | throw new TypeError( "Thenable self-resolution" ); |
| 3772 | } |
| 3773 | |
| 3774 | // Support: Promises/A+ sections 2.3.3.1, 3.5 |
| 3775 | // https://promisesaplus.com/#point-54 |
| 3776 | // https://promisesaplus.com/#point-75 |
| 3777 | // Retrieve `then` only once |
| 3778 | then = returned && |
| 3779 | |
| 3780 | // Support: Promises/A+ section 2.3.4 |
| 3781 | // https://promisesaplus.com/#point-64 |
| 3782 | // Only check objects and functions for thenability |
| 3783 | ( typeof returned === "object" || |
| 3784 | typeof returned === "function" ) && |
| 3785 | returned.then; |
| 3786 | |
| 3787 | // Handle a returned thenable |
| 3788 | if ( isFunction( then ) ) { |
| 3789 | |
| 3790 | // Special processors (notify) just wait for resolution |
| 3791 | if ( special ) { |
| 3792 | then.call( |
| 3793 | returned, |
| 3794 | resolve( maxDepth, deferred, Identity, special ), |
| 3795 | resolve( maxDepth, deferred, Thrower, special ) |
| 3796 | ); |
| 3797 | |
| 3798 | // Normal processors (resolve) also hook into progress |
| 3799 | } else { |
| 3800 | |
| 3801 | // ...and disregard older resolution values |
| 3802 | maxDepth++; |
| 3803 | |
| 3804 | then.call( |
| 3805 | returned, |
| 3806 | resolve( maxDepth, deferred, Identity, special ), |
| 3807 | resolve( maxDepth, deferred, Thrower, special ), |
| 3808 | resolve( maxDepth, deferred, Identity, |
| 3809 | deferred.notifyWith ) |
| 3810 | ); |
| 3811 | } |
| 3812 | |
| 3813 | // Handle all other returned values |
no test coverage detected