[Pkg-javascript-commits] [dojo] 18/23: Remove references to globals through `this` in AMD factories

David Prévot taffit at moszumanska.debian.org
Sun Sep 14 16:23:12 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.9.4
in repository dojo.

commit dcebb97df09699d3e3517dac7189239e0b13880e
Author: Colin Snover <github.com at zetafleet.com>
Date:   Fri Aug 22 23:17:34 2014 +0000

    Remove references to globals through `this` in AMD factories
    
    Fixes #17829
    
    (cherry picked from commit fa4028b647e38d4f1cc183e6db65022f80cb5423)
---
 _base/config.js   | 3 ++-
 _base/kernel.js   | 5 +++--
 _base/window.js   | 2 +-
 domReady.js       | 2 +-
 has.js            | 2 +-
 request/script.js | 5 +++--
 6 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/_base/config.js b/_base/config.js
index d94d9c8..88f184c 100644
--- a/_base/config.js
+++ b/_base/config.js
@@ -174,11 +174,12 @@ return {
 				p!="has" && has.add(prefix + p, featureSet[p], 0, booting);
 			}
 		};
+		var global = (function () { return this; })();
 		result = has("dojo-loader") ?
 			// must be a built version of the dojo loader; all config stuffed in require.rawConfig
 			require.rawConfig :
 			// a foreign loader
-			this.dojoConfig || this.djConfig || {};
+			global.dojoConfig || global.djConfig || {};
 		adviseHas(result, "config", 1);
 		adviseHas(result.has, "", 1);
 	}
diff --git a/_base/kernel.js b/_base/kernel.js
index 0ae15de..d3d0f43 100644
--- a/_base/kernel.js
+++ b/_base/kernel.js
@@ -10,6 +10,7 @@ define(["../has", "./config", "require", "module"], function(has, config, requir
 
 		// create dojo, dijit, and dojox
 		// FIXME: in 2.0 remove dijit, dojox being created by dojo
+		global = (function () { return this; })(),
 		dijit = {},
 		dojox = {},
 		dojo = {
@@ -18,7 +19,7 @@ define(["../has", "./config", "require", "module"], function(has, config, requir
 
 			// notice dojo takes ownership of the value of the config module
 			config:config,
-			global:this,
+			global:global,
 			dijit:dijit,
 			dojox:dojox
 		};
@@ -67,7 +68,7 @@ define(["../has", "./config", "require", "module"], function(has, config, requir
 		item = scopeMap[p];
 		item[1]._scopeName = item[0];
 		if(!config.noGlobals){
-			this[item[0]] = item[1];
+			global[item[0]] = item[1];
 		}
 	}
 	dojo.scopeMap = scopeMap;
diff --git a/_base/window.js b/_base/window.js
index df479b1..45cc7a3 100644
--- a/_base/window.js
+++ b/_base/window.js
@@ -18,7 +18,7 @@ var ret = {
 	 },
 	 =====*/
 
-	doc: this["document"] || null,
+	doc: dojo.global["document"] || null,
 	/*=====
 	doc: {
 		// summary:
diff --git a/domReady.js b/domReady.js
index 8c1da71..62d5eb2 100644
--- a/domReady.js
+++ b/domReady.js
@@ -1,5 +1,5 @@
 define(['./has'], function(has){
-	var global = this,
+	var global = (function () { return this; })(),
 		doc = document,
 		readyStates = { 'loaded': 1, 'complete': 1 },
 		fixReadyState = typeof doc.readyState != "string",
diff --git a/has.js b/has.js
index f82a369..e6b1a1a 100644
--- a/has.js
+++ b/has.js
@@ -26,7 +26,7 @@ define(["require", "module"], function(require, module){
 				window.location == location && window.document == document,
 
 			// has API variables
-			global = this,
+			global = (function () { return this; })(),
 			doc = isBrowser && document,
 			element = doc && doc.createElement("DiV"),
 			cache = (module.config && module.config()) || {};
diff --git a/request/script.js b/request/script.js
index b0ee148..e9882ed 100644
--- a/request/script.js
+++ b/request/script.js
@@ -2,6 +2,7 @@ define([
 	'module',
 	'./watch',
 	'./util',
+	'../_base/kernel',
 	'../_base/array',
 	'../_base/lang',
 	'../on',
@@ -11,7 +12,7 @@ define([
 	'../_base/window'/*=====,
 	'../request',
 	'../_base/declare' =====*/
-], function(module, watch, util, array, lang, on, dom, domConstruct, has, win/*=====, request, declare =====*/){
+], function(module, watch, util, kernel, array, lang, on, dom, domConstruct, has, win/*=====, request, declare =====*/){
 	has.add('script-readystatechange', function(global, document){
 		var script = document.createElement('script');
 		return typeof script['onreadystatechange'] !== 'undefined' &&
@@ -22,7 +23,7 @@ define([
 		counter = 0,
 		loadEvent = has('script-readystatechange') ? 'readystatechange' : 'load',
 		readyRegExp = /complete|loaded/,
-		callbacks = this[mid + '_callbacks'] = {},
+		callbacks = kernel.global[mid + '_callbacks'] = {},
 		deadScripts = [];
 
 	function attach(id, url, frameDoc){

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list