Created
October 7, 2011 18:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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