Skip to content

Instantly share code, notes, and snippets.

@ExtAnimal
Created October 7, 2011 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ExtAnimal/1271015 to your computer and use it in GitHub Desktop.
Save ExtAnimal/1271015 to your computer and use it in GitHub Desktop.
platform/core/source/Ext.js Avoiding placing a reference to the Ext namespace as a DOM property on window
getUniqueGlobalNamespace: function() {
var uniqueGlobalNamespace = this.uniqueGlobalNamespace;
if (uniqueGlobalNamespace === undefined) {
var i = 0;
do {
uniqueGlobalNamespace = 'ExtBox' + (++i);
} while (Ext.global[uniqueGlobalNamespace] !== undefined);
new Function(uniqueGlobalNamespace + '=this').call(Ext);
this.uniqueGlobalNamespace = uniqueGlobalNamespace;
}
return uniqueGlobalNamespace;
},
/**
* @private
*/
functionFactory: function() {
var args = Array.prototype.slice.call(arguments),
ln = args.length;
if (ln > 0) {
args[ln - 1] = 'var Ext=' + this.getUniqueGlobalNamespace() + ';' + args[ln - 1];
}
return Function.prototype.constructor.apply(Function.prototype, args);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment