Make getGlobal() work in strict mode
An update of https://github.com/metaweta/jasmine/commit/fb3e1acb09b4dbb9ccdbc15ce64b4a0e471f4541 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:
+6
-7
@@ -1,3 +1,4 @@
|
|||||||
|
getJasmineRequireObj().global = this;
|
||||||
getJasmineRequireObj().base = function(j$) {
|
getJasmineRequireObj().base = function(j$) {
|
||||||
j$.unimplementedMethod_ = function() {
|
j$.unimplementedMethod_ = function() {
|
||||||
throw new Error("unimplemented method");
|
throw new Error("unimplemented method");
|
||||||
@@ -6,13 +7,11 @@ getJasmineRequireObj().base = function(j$) {
|
|||||||
j$.MAX_PRETTY_PRINT_DEPTH = 40;
|
j$.MAX_PRETTY_PRINT_DEPTH = 40;
|
||||||
j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
||||||
|
|
||||||
j$.getGlobal = function() {
|
j$.getGlobal = (function(global) {
|
||||||
function getGlobal() {
|
return function() {
|
||||||
return this;
|
return global;
|
||||||
}
|
};
|
||||||
|
})(this.global); // Here, this === getJasmineRequireObj()
|
||||||
return getGlobal();
|
|
||||||
};
|
|
||||||
|
|
||||||
j$.getEnv = function(options) {
|
j$.getEnv = function(options) {
|
||||||
var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
|
var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
|
||||||
|
|||||||
Reference in New Issue
Block a user