Changeset 13145
- Timestamp:
- 03/19/08 06:04:23 (10 months ago)
- Location:
- dojo/trunk
- Files:
-
- 2 modified
-
tests/_base/_loader/addLoadEvents.html (modified) (1 diff)
-
_base/_loader/loader.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojo/trunk/tests/_base/_loader/addLoadEvents.html
r10248 r13145 8 8 <script type="text/javascript"> 9 9 dojo.addOnLoad(function(){ 10 alert("addOnLoadworks");10 console.debug("addOnLoad(func) works"); 11 11 }); 12 var scope = { 13 named: function(){ console.debug("addOnLoad(obj, name) works"); }, 14 refd: function(){ console.debug("addOnLoad(obj, func) works"); } 15 }; 16 dojo.addOnLoad(scope, "named"); 17 dojo.addOnLoad(scope, scope.refd); 18 // dojo.addOnLoad(scope, "named"); 19 // dojo.addOnLoad(scope, scope.refd); 20 12 21 dojo.addOnUnload(function(){ 13 22 alert("addOnUnload works"); -
dojo/trunk/_base/_loader/loader.js
r12942 r13145 146 146 mll[x](); 147 147 }catch(e){ 148 throw e; 148 149 console.error("dojo.addOnLoad callback failed: " + e, e); /* let other load events fire, like the parser, but report the error */ 149 150 } … … 168 169 while(mll.length){ 169 170 (mll.pop())(); 171 } 172 } 173 174 var onto = function(arr, obj, fn){ 175 if(!fn){ 176 arr.push(obj); 177 }else if(fn){ 178 var func = (typeof fn == "string") ? obj[fn] : fn; 179 arr.push(function(){ func.call(obj); }); 170 180 } 171 181 } … … 182 192 // | dojo.addOnLoad(functionPointer); 183 193 // | dojo.addOnLoad(object, "functionName"); 184 if(arguments.length == 1){ 185 d._loaders.push(obj); 186 }else if(arguments.length > 1){ 187 d._loaders.push(function(){ 188 obj[functionName](); 189 }); 190 } 194 // | dojo.addOnLoad(object, function(){ /* ... */}); 195 196 onto(d._loaders, obj, functionName); 191 197 192 198 //Added for xdomain loading. dojo.addOnLoad is used to … … 200 206 201 207 dojo.addOnUnload = function(/*Object?*/obj, /*String|Function?*/functionName){ 202 // summary: registers a function to be triggered when the page unloads 208 // summary: 209 // registers a function to be triggered when the page unloads 203 210 // example: 204 211 // | dojo.addOnUnload(functionPointer) 205 212 // | dojo.addOnUnload(object, "functionName") 206 if(arguments.length == 1){ 207 d._unloaders.push(obj); 208 }else if(arguments.length > 1){ 209 d._unloaders.push(function(){ 210 obj[functionName](); 211 }); 212 } 213 // | dojo.addOnUnload(object, function(){ /* ... */}); 214 215 onto(d._unloaders, obj, functionName); 213 216 } 214 217 … … 223 226 224 227 dojo._callLoaded = function(){ 225 //The "object" check is for IE, and the other opera check fixes an issue 226 //in Opera where it could not find the body element in some widget test cases. 227 //For 0.9, maybe route all browsers through the setTimeout (need protection 228 //still for non-browser environments though). This might also help the issue with 229 //FF 2.0 and freezing issues where we try to do sync xhr while background css images 230 //are being loaded (trac #2572)? Consider for 0.9. 228 229 // The "object" check is for IE, and the other opera check fixes an 230 // issue in Opera where it could not find the body element in some 231 // widget test cases. For 0.9, maybe route all browsers through the 232 // setTimeout (need protection still for non-browser environments 233 // though). This might also help the issue with FF 2.0 and freezing 234 // issues where we try to do sync xhr while background css images are 235 // being loaded (trac #2572)? Consider for 0.9. 231 236 if(typeof setTimeout == "object" || (dojo.config.useXDomain && d.isOpera)){ 232 237 if(dojo.isAIR){