Make getGlobal() work in strict mode

An update of fb3e1acb09

ES5 strict mode does not promote an undefined 'this' to the global object.  The only way to get the global object in strict mode is to say 'this' while in the global scope.
This commit is contained in:
Mike Stay
2013-10-02 12:38:25 -06:00
parent 37a3135d6a
commit ffa6138d75

View File

@@ -1,3 +1,4 @@
getJasmineRequireObj().global = this;
getJasmineRequireObj().base = function(j$) {
j$.unimplementedMethod_ = function() {
throw new Error("unimplemented method");
@@ -6,13 +7,11 @@ getJasmineRequireObj().base = function(j$) {
j$.MAX_PRETTY_PRINT_DEPTH = 40;
j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
j$.getGlobal = function() {
function getGlobal() {
return this;
}
return getGlobal();
};
j$.getGlobal = (function(global) {
return function() {
return global;
};
})(this.global); // Here, this === getJasmineRequireObj()
j$.getEnv = function(options) {
var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);