Changeset 11216

Show
Ignore:
Timestamp:
10/30/07 03:30:35 (13 months ago)
Author:
alex
Message:

make dojo.delegate public and add docs. Refs #4820

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/_base/lang.js

    r11205 r11216  
    4141 
    4242dojo.isArrayLike = function(/*anything*/ it){ 
    43         // return: 
     43        //      summary: 
     44        //              similar to dojo.isArray() but more permissive 
     45        //      description: 
     46        //              Doesn't strongly test for "arrayness".  Instead, settles for "isn't 
     47        //              a string or number and has a length property". Arguments objects 
     48        //              and DOM collections will return true when passed to 
     49        //              dojo.isArrayLike(), but will return false when passed to 
     50        //              dojo.isArray(). 
     51        //      return: 
    4452        //              If it walks like a duck and quicks like a duck, return true 
    4553        var d = dojo; 
     
    120128} 
    121129 
    122 dojo._delegate = function(obj, props){ 
     130/*===== 
     131dojo.delegate = function(obj, props){ 
     132        //      summary: 
     133        //              returns a new object which "looks" to obj for properties which it 
     134        //              does not have a value for. Optionally takes a bag of properties to 
     135        //              seed the returned object with initially.  
     136        //      description: 
     137        //              This is a small implementaton of the Boodman/Crockford delegation 
     138        //              pattern in JavaScript. An intermediate object constructor mediates 
     139        //              the prototype chain for the returned object, using it to delegate 
     140        //              down to obj for property lookup when object-local lookup fails. 
     141        //              This can be thought of similarly to ES4's "wrap", save that it does 
     142        //              not act on types but rather on pure objects. 
     143        //      obj: 
     144        //              The object to delegate to for properties not found directly on the 
     145        //              return object or in props. 
     146        //      props: 
     147        //              an object containing properties to assign to the returned object 
     148        //      returns: 
     149        //              an Object of anonymous type 
     150        //      example: 
     151        //      |       var foo = { bar: "baz" }; 
     152        //      |       var thinger = dojo.delegate(foo, { thud: "xyzzy"}); 
     153        //      |       thinger.bar == "baz"; // delegated to foo 
     154        //      |       foo.xyzzy == undefined; // by definition 
     155        //      |       thinger.xyzzy == "xyzzy"; // mixed in from props 
     156        //      |       foo.bar = "thonk"; 
     157        //      |       thinger.bar == "thonk"; // still delegated to foo's bar 
     158} 
     159=====*/ 
     160 
     161 
     162dojo.delegate = dojo._delegate = function(obj, props){ 
     163 
    123164        // boodman/crockford delegation 
    124165        function TMP(){};