| 122 | | dojo._delegate = function(obj, props){ |
| | 130 | /*===== |
| | 131 | dojo.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 | |
| | 162 | dojo.delegate = dojo._delegate = function(obj, props){ |
| | 163 | |