diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2012-04-26 16:08:17 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2012-04-26 16:08:17 -0400 |
commit | a25721a2cdf9e6cc105993ce70a0a2b8cef30dd8 (patch) | |
tree | 473a23097d9a69d218ce0e237da7bb3c81748e1e /src/deferred.js | |
parent | 6e066a4db72ff6b0d12dd8a43faec0a80e4a1fed (diff) | |
download | jquery-a25721a2cdf9e6cc105993ce70a0a2b8cef30dd8.tar.gz jquery-a25721a2cdf9e6cc105993ce70a0a2b8cef30dd8.zip |
code compression
Diffstat (limited to 'src/deferred.js')
-rw-r--r-- | src/deferred.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/deferred.js b/src/deferred.js index e39502783..a6a3f4219 100644 --- a/src/deferred.js +++ b/src/deferred.js @@ -7,9 +7,9 @@ jQuery.extend({ Deferred: function( func ) { var tuples = [ - // action, add listener, listener list - [ "resolve", "done", jQuery.Callbacks("once memory") ], - [ "reject", "fail", jQuery.Callbacks("once memory") ], + // action, add listener, listener list, final state + [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], + [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], [ "notify", "progress", jQuery.Callbacks("memory") ] ], state = "pending", @@ -59,19 +59,22 @@ jQuery.extend({ // Add list-specific methods jQuery.each( tuples, function( i, tuple ) { - var list = tuple[ 2 ], stateString; + var list = tuple[ 2 ], + stateString = tuple[ 3 ]; // promise[ done | fail | progress ] = list.add promise[ tuple[1] ] = list.add; // Handle state if ( i < 2 ) { - stateString = tuple[ 0 ].replace( /e?$/, "ed" ); list.add(function() { + // state = [ resolved | rejected ] state = stateString; - tuples[ i ^ 1 ][ 2 ].disable(); - tuples[ 2 ][ 2 ].lock(); - }); + + // [ reject_list | resolve_list ].disable; progress_list.lock + }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); + + // [ isResolved | isRejected ] = [ resolve_list | reject_list ].fired promise[ "isR" + stateString.substr( 1 ) ] = list.fired; } |