Changeset 7989
- Timestamp:
- 04/07/07 16:02:39 (20 months ago)
- Location:
- dojo/trunk
- Files:
-
- 11 modified
-
data/util/simpleFetch.js (modified) (2 diffs)
-
tests/_base/_loader/bootstrap.js (modified) (4 diffs)
-
_base/array.js (modified) (2 diffs)
-
_base/Deferred.js (modified) (1 diff)
-
_base/html.js (modified) (4 diffs)
-
_base/lang.js (modified) (2 diffs)
-
_base/NodeList.js (modified) (1 diff)
-
_base/query.js (modified) (2 diffs)
-
_base/_loader/bootstrap.js (modified) (6 diffs)
-
_base/_loader/hostenv_browser.js (modified) (4 diffs)
-
_base/_loader/hostenv_rhino.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dojo/trunk/data/util/simpleFetch.js
r7969 r7989 37 37 var _errorHandler = function(errorData){ 38 38 if(request.onError){ 39 var scope = request.scope || dojo.global ();39 var scope = request.scope || dojo.global; 40 40 request.onError.call(scope, errorData); 41 41 } … … 56 56 }; 57 57 58 var scope = requestObject.scope || dojo.global ();58 var scope = requestObject.scope || dojo.global; 59 59 if(!requestObject.store){ 60 60 requestObject.store = self; -
dojo/trunk/tests/_base/_loader/bootstrap.js
r7894 r7989 5 5 6 6 function hasConsole(t){ 7 t.assertTrue("console" in dojo.global ());7 t.assertTrue("console" in dojo.global); 8 8 t.assertTrue("assert" in console); 9 9 t.assertEqual("function", typeof console.assert); … … 11 11 12 12 function hasDjConfig(t){ 13 t.assertTrue("djConfig" in dojo.global ());13 t.assertTrue("djConfig" in dojo.global); 14 14 }, 15 15 … … 18 18 setUp: function(){ 19 19 //Set an object in global scope. 20 dojo.global ().globalValue = {20 dojo.global.globalValue = { 21 21 color: "blue", 22 22 size: 20 … … 60 60 //the test is re-run. 61 61 try{ 62 delete dojo.global ().something;62 delete dojo.global.something; 63 63 delete this.something; 64 64 }catch(e){} -
dojo/trunk/_base/array.js
r7777 r7989 12 12 }else{ 13 13 var _getParts = function(arr, obj){ 14 return [ (d.isString(arr) ? arr.split("") : arr), (obj||d.global ()) ];14 return [ (d.isString(arr) ? arr.split("") : arr), (obj||d.global) ]; 15 15 } 16 16 … … 89 89 90 90 // FIXME: there are several ways of handilng thisObject. Is 91 // dojo.global ()always the default context?91 // dojo.global always the default context? 92 92 var _p = _getParts(arr, obj); arr = _p[0]; obj = _p[1]; 93 93 for(var i=0,l=arr.length; i<l; i++){ -
dojo/trunk/_base/Deferred.js
r7732 r7989 232 232 return a[0]; 233 233 }else if(dojo.isString(a[0])){ 234 return dojo.global ()[a[0]];234 return dojo.global[a[0]]; 235 235 } 236 236 }else if((a[0])&&(a[1])){ -
dojo/trunk/_base/html.js
r7984 r7989 14 14 // doc: 15 15 // optional, defaults to the current value of 16 // dojo. _currentDocument. Can be used to retreive16 // dojo.doc. Can be used to retreive 17 17 // node references from other documents. 18 18 19 19 if(dojo.isString(id)){ 20 var _d = (doc||dojo.doc ());20 var _d = (doc||dojo.doc); 21 21 var te = _d.getElementById(id); 22 22 if((te) && (te.id == id)){ … … 48 48 // doc: 49 49 // optional, defaults to the current value of 50 // dojo. _currentDocument. Can be used to retreive50 // dojo.doc. Can be used to retreive 51 51 // node references from other documents. 52 52 if(dojo.isString(id)){ 53 return (doc||dojo.doc ()).getElementById(id);53 return (doc||dojo.doc).getElementById(id); 54 54 }else{ 55 55 return id; // DomNode … … 295 295 var _docScroll = function(){ 296 296 var _b = dojo.body(); 297 var _w = dojo.global ();298 var de = dojo.doc ().documentElement;297 var _w = dojo.global; 298 var de = dojo.doc.documentElement; 299 299 return { 300 300 y: (_w.pageYOffset || de.scrollTop || _b.scrollTop || 0), … … 312 312 // FIXME: need to decide in the brave-new-world if we're going to be 313 313 // margin-box or border-box. 314 var ownerDocument = dojo.doc ();314 var ownerDocument = dojo.doc; 315 315 var ret = { 316 316 x: 0, -
dojo/trunk/_base/lang.js
r7988 r7989 112 112 } 113 113 // locate our method 114 var f = (named ? (scope||dojo.global ())[method] : method);114 var f = (named ? (scope||dojo.global)[method] : method); 115 115 // invoke with collected args 116 116 return (f)&&(f.apply(scope||this, pre.concat(args))); // Any … … 139 139 return dojo._hitchArgs.apply(dojo, arguments); 140 140 }else if(dojo.isString(method)){ 141 scope = scope || dojo.global ();141 scope = scope || dojo.global; 142 142 return function(){ return scope[method].apply(scope, arguments||[]); } 143 143 }else{ -
dojo/trunk/_base/NodeList.js
r7960 r7989 174 174 // "after" 175 175 // or an offset in the childNodes property 176 var ta = dojo.doc ().createElement("span");176 var ta = dojo.doc.createElement("span"); 177 177 if(dojo.isString(content)){ 178 178 ta.innerHTML = content; -
dojo/trunk/_base/query.js
r7977 r7989 206 206 } 207 207 208 var doc = d.doc ();208 var doc = d.doc; 209 209 // var parent = d.body(); // FIXME 210 210 // FIXME: don't need to memoize. The closure scope handles it for us. … … 1042 1042 1043 1043 // FIXME: should support more methods on the return than the stock array. 1044 return _zip(getQueryFunc(query)(root||dojo.doc ()));1044 return _zip(getQueryFunc(query)(root||dojo.doc)); 1045 1045 } 1046 1046 -
dojo/trunk/_base/_loader/bootstrap.js
r7988 r7989 48 48 } 49 49 50 dojo._currentContext = this; 51 52 dojo.global = function(){ 53 // summary: 54 // return the current global context object 55 // (e.g., the window object in a browser). 56 // description: 57 // Refer to 'dojo.global()' rather than referring to window to ensure your 58 // code runs correctly in contexts other than web browsers (eg: Rhino on a server). 59 return this._currentContext; 60 } 50 // summary: 51 // return the current global context object 52 // (e.g., the window object in a browser). 53 // description: 54 // Refer to 'dojo.global' rather than referring to window to ensure your 55 // code runs correctly in contexts other than web browsers (eg: Rhino on a server). 56 dojo.global = this; 61 57 62 58 var _config = { … … 100 96 101 97 dojo._getProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){ 102 var obj=context||dojo.global ();98 var obj=context||dojo.global; 103 99 for(var i=0, p; obj&&(p=parts[i]); i++){ 104 100 obj = (p in obj ? obj[p] : (create ? obj[p]={} : undefined)); … … 118 114 // context: 119 115 // Optional. Object to use as root of path. Defaults to 120 // 'dojo.global ()'. Null may be passed.116 // 'dojo.global'. Null may be passed. 121 117 var parts=name.split("."), p=parts.pop(), obj=dojo._getProp(parts, true, context); 122 118 return (obj && p ? (obj[p]=value) : undefined); // Any … … 133 129 // context: 134 130 // Optional. Object to use as root of path. Defaults to 135 // 'dojo.global ()'. Null may be passed.131 // 'dojo.global'. Null may be passed. 136 132 // create: 137 133 // Optional. If true, Objects will be created at any point along the … … 150 146 // obj: 151 147 // Optional. Object to use as root of path. Defaults to 152 // 'dojo.global ()'. Null may be passed.148 // 'dojo.global'. Null may be passed. 153 149 return Boolean(dojo.getObject(name, false, obj)); // Boolean 154 150 } … … 170 166 // see also: 171 167 // http://trac.dojotoolkit.org/ticket/744 172 return dojo.global ().eval ? dojo.global().eval(scriptFragment) : eval(scriptFragment); // mixed168 return dojo.global.eval ? dojo.global.eval(scriptFragment) : eval(scriptFragment); // mixed 173 169 } 174 170 -
dojo/trunk/_base/_loader/hostenv_browser.js
r7963 r7989 247 247 dojo._writeIncludes = function(){} 248 248 249 //TODOC: HOW TO DOC THIS? 250 // @global: dojo._currentDocument 249 // @global: dojo.doc 251 250 // summary: 252 // Current document object. 'dojo. _currentDocument' can be modified253 // for temporary context shifting. 251 // Current document object. 'dojo.doc' can be modified 252 // for temporary context shifting. Also see dojo.withDoc(). 254 253 // description: 255 // dojo.doc() returns dojo._currentDocument. Refer to dojo.doc()rather254 // Refer to dojo.doc rather 256 255 // than referring to 'window.document' to ensure your code runs 257 256 // correctly in managed contexts. 258 if(window["document"]){ 259 dojo._currentDocument = window.document; 260 } 261 262 dojo.doc = function(){ 263 // summary: 264 // return the document object associated with the dojo.global() 265 return dojo._currentDocument; 266 } 257 dojo.doc = window["document"] || null; 267 258 268 259 dojo.body = function(){ 269 260 // summary: 270 // return the body object associated with dojo.doc ()261 // return the body object associated with dojo.doc 271 262 272 263 // Note: document.body is not defined for a strict xhtml document 273 return dojo.doc().body || dojo.doc().getElementsByTagName("body")[0]; 264 // Would like to memoize this, but dojo.doc can change vi dojo.withDoc(). 265 return dojo.doc.body || dojo.doc.getElementsByTagName("body")[0]; 274 266 } 275 267 … … 278 270 // changes the behavior of many core Dojo functions that deal with 279 271 // namespace and DOM lookup, changing them to work in a new global 280 // context. The varibles dojo. _currentContext and dojo._currentDocument272 // context. The varibles dojo.global and dojo.doc 281 273 // are modified as a result of calling this function. 282 dojo. _currentContext= globalObject;283 dojo. _currentDocument= globalDocument;274 dojo.global = globalObject; 275 dojo.doc = globalDocument; 284 276 }; 285 277 … … 296 288 /*Array?*/cbArguments){ 297 289 // summary: 298 // Call callback with globalObject as dojo.global ()and299 // globalObject.document as dojo.doc (). If provided, globalObject290 // Call callback with globalObject as dojo.global and 291 // globalObject.document as dojo.doc. If provided, globalObject 300 292 // will be executed in the context of object thisObject 301 293 // description: 302 // When callback() returns or throws an error, the dojo.global ()303 // and dojo.doc ()will be restored to its previous state.294 // When callback() returns or throws an error, the dojo.global 295 // and dojo.doc will be restored to its previous state. 304 296 var rval; 305 var oldGlob = dojo. _currentContext;306 var oldDoc = dojo. _currentDocument;297 var oldGlob = dojo.global; 298 var oldDoc = dojo.doc; 307 299 try{ 308 300 dojo.setContext(globalObject, globalObject.document); … … 319 311 /*Array?*/cbArguments){ 320 312 // summary: 321 // Call callback with documentObject as dojo.doc (). If provided,313 // Call callback with documentObject as dojo.doc. If provided, 322 314 // callback will be executed in the context of object thisObject 323 315 // description: 324 // When callback() returns or throws an error, the dojo.doc ()will316 // When callback() returns or throws an error, the dojo.doc will 325 317 // be restored to its previous state. 326 318 var rval; 327 var oldDoc = dojo. _currentDocument;319 var oldDoc = dojo.doc; 328 320 try{ 329 dojo. _currentDocument= documentObject;321 dojo.doc = documentObject; 330 322 rval = dojo._fireCallback(callback, thisObject, cbArguments); 331 323 }finally{ 332 dojo. _currentDocument= oldDoc;324 dojo.doc = oldDoc; 333 325 } 334 326 return rval; -
dojo/trunk/_base/_loader/hostenv_rhino.js
r7963 r7989 185 185 } 186 186 187 dojo.doc = function(){ 188 // summary: 189 // return the document object associated with the dojo.global() 190 return document; 191 } 187 // summary: 188 // return the document object associated with the dojo.global 189 dojo.doc = typeof(document) != "undefined" ? document : null; 192 190 193 191 dojo.body = function(){