Use globalThis to determine the global object during initialization

This slightly simplifies the init code and hardens Jasmine against broken
bundlers that assume everything can be wrapped in a "use strict" context.

This removes a workaround for incompatible `this` behavior in GJS. GJS was
never a supported envronment, but in any case the change is unlikely to
cause problems since GJS ha supported globalThis since 2020.
This commit is contained in:
Steve Gravrock
2025-10-05 06:59:05 -07:00
parent 68a7cbb991
commit c4abf3265d
2 changed files with 6 additions and 26 deletions

View File

@@ -32,20 +32,10 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
module.exports &&
typeof exports !== 'undefined'
) {
if (typeof global !== 'undefined') {
jasmineGlobal = global;
} else {
jasmineGlobal = {};
}
// Node
jasmineRequire = exports;
} else {
if (
typeof window !== 'undefined' &&
typeof window.toString === 'function' &&
window.toString() === '[object GjsGlobal]'
) {
jasmineGlobal = window;
}
// Browser
jasmineRequire = jasmineGlobal.jasmineRequire = {};
}
@@ -56,7 +46,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
getJasmineRequire().core = function(jRequire) {
const j$ = { private: {} };
jRequire.base(j$, jasmineGlobal);
jRequire.base(j$, globalThis);
j$.private.util = jRequire.util(j$);
j$.private.errors = jRequire.errors();
j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$);

View File

@@ -8,20 +8,10 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
module.exports &&
typeof exports !== 'undefined'
) {
if (typeof global !== 'undefined') {
jasmineGlobal = global;
} else {
jasmineGlobal = {};
}
// Node
jasmineRequire = exports;
} else {
if (
typeof window !== 'undefined' &&
typeof window.toString === 'function' &&
window.toString() === '[object GjsGlobal]'
) {
jasmineGlobal = window;
}
// Browser
jasmineRequire = jasmineGlobal.jasmineRequire = {};
}
@@ -32,7 +22,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
getJasmineRequire().core = function(jRequire) {
const j$ = { private: {} };
jRequire.base(j$, jasmineGlobal);
jRequire.base(j$, globalThis);
j$.private.util = jRequire.util(j$);
j$.private.errors = jRequire.errors();
j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$);