Changeset 12828

Show
Ignore:
Timestamp:
03/03/08 04:13:09 (9 months ago)
Author:
alex
Message:

comment cleanup and code shortening. Also expanding test cases to handle default param packing. Refs #3961. Refs #5962. Refs #3121. !strict

Location:
dojo/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/tests/_base/Deferred.js

    r8301 r12828  
    1919                        // t.debug("cnt:", cnt); 
    2020                        t.assertEqual(cnt, 5); 
     21                }, 
     22 
     23                function callback_extra_args(t){ 
     24                        var nd = new dojo.Deferred(); 
     25                        var cnt = 0; 
     26                        nd.addCallback(window, function(base, res){ cnt+=base; cnt+=res; return cnt; }, 30); 
     27                        nd.callback(5); 
     28                        t.assertEqual(cnt, 35); 
    2129                }, 
    2230 
  • dojo/trunk/_base/Deferred.js

    r11356 r12828  
    301301 
    302302        callback: function(res){ 
    303                 // summary:     Begin the callback sequence with a non-error value. 
     303                //      summary:         
     304                //              Begin the callback sequence with a non-error value. 
    304305                 
    305306                /* 
     
    312313 
    313314        errback: function(/*Error*/res){ 
    314                 // summary:  
     315                //      summary:  
    315316                //              Begin the callback sequence with an error result. 
    316317                this._check(); 
     
    321322        }, 
    322323 
    323         addBoth: function(/*Function||Object*/cb, /*Optional, String*/cbfn){ 
    324                 // summary: 
     324        addBoth: function(/*Function|Object*/cb, /*String?*/cbfn){ 
     325                //      summary: 
    325326                //              Add the same function as both a callback and an errback as the 
    326                 //              next element on the callback sequence.  This is useful for code 
     327                //              next element on the callback sequence.This is useful for code 
    327328                //              that you want to guarantee to run, e.g. a finalizer. 
    328                 var enclosed = dojo.hitch(cb, cbfn); 
    329                 if(arguments.length > 2){ 
    330                         enclosed = dojo.partial(enclosed, arguments, 2); 
    331                 } 
     329                var enclosed = dojo.hitch.apply(dojo, arguments); 
    332330                return this.addCallbacks(enclosed, enclosed); 
    333331        }, 
    334332 
    335         addCallback: function(cb, cbfn){ 
    336                 // summary:  
     333        addCallback: function(/*Function|Object*/cb, /*String?*/cbfn /*...*/){ 
     334                //      summary:  
    337335                //              Add a single callback to the end of the callback sequence. 
    338                 var enclosed = dojo.hitch(cb, cbfn); 
    339                 if(arguments.length > 2){ 
    340                         enclosed = dojo.partial(enclosed, arguments, 2); 
    341                 } 
    342                 return this.addCallbacks(enclosed, null); 
     336                return this.addCallbacks(dojo.hitch.apply(dojo, arguments)); 
    343337        }, 
    344338 
    345339        addErrback: function(cb, cbfn){ 
    346                 // summary:  
     340                //      summary:  
    347341                //              Add a single callback to the end of the callback sequence. 
    348                 var enclosed = dojo.hitch(cb, cbfn); 
    349                 if(arguments.length > 2){ 
    350                         enclosed = dojo.partial(enclosed, arguments, 2); 
    351                 } 
    352                 return this.addCallbacks(null, enclosed); 
     342                return this.addCallbacks(null, dojo.hitch.apply(dojo, arguments)); 
    353343        }, 
    354344