diff --git a/js/ui/environment.js b/js/ui/environment.js index 7a96d9480..4a1231402 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -245,16 +245,15 @@ function _loggingFunc(...args) { } function init() { - // Add some bindings to the global JS namespace; (gjs keeps the web - // browser convention of having that namespace be called 'window'.) - window.global = Shell.Global.get(); + // Add some bindings to the global JS namespace + globalThis.global = Shell.Global.get(); - window.log = _loggingFunc; + globalThis.log = _loggingFunc; - window._ = Gettext.gettext; - window.C_ = Gettext.pgettext; - window.ngettext = Gettext.ngettext; - window.N_ = s => s; + globalThis._ = Gettext.gettext; + globalThis.C_ = Gettext.pgettext; + globalThis.ngettext = Gettext.ngettext; + globalThis.N_ = s => s; GObject.gtypeNameBasedOnJSPath = true; diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 838a0c833..6ef8ddae3 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -37,8 +37,8 @@ const LG_ANIMATION_TIME = 500; function _getAutoCompleteGlobalKeywords() { const keywords = ['true', 'false', 'null', 'new']; - // Don't add the private properties of window (i.e., ones starting with '_') - const windowProperties = Object.getOwnPropertyNames(window).filter( + // Don't add the private properties of globalThis (i.e., ones starting with '_') + const windowProperties = Object.getOwnPropertyNames(globalThis).filter( a => a.charAt(0) != '_' ); const headerProperties = JsParse.getDeclaredConstants(commandHeader); diff --git a/js/ui/main.js b/js/ui/main.js index 3fcc8b285..f1f069af4 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -125,8 +125,8 @@ function _sessionUpdated() { function start() { // These are here so we don't break compatibility. - global.logError = window.log; - global.log = window.log; + global.logError = globalThis.log; + global.log = globalThis.log; // Chain up async errors reported from C global.connect('notify-error', (global, msg, detail) => { diff --git a/lint/eslintrc-gjs.yml b/lint/eslintrc-gjs.yml index fec07a409..3fa6b86b5 100644 --- a/lint/eslintrc-gjs.yml +++ b/lint/eslintrc-gjs.yml @@ -218,12 +218,12 @@ globals: ARGV: readonly Debugger: readonly GIRepositoryGType: readonly + globalThis: readonly imports: readonly Intl: readonly log: readonly logError: readonly print: readonly printerr: readonly - window: readonly parserOptions: ecmaVersion: 2019 diff --git a/subprojects/extensions-app/js/main.js b/subprojects/extensions-app/js/main.js index 00b6c047d..25804e5ba 100644 --- a/subprojects/extensions-app/js/main.js +++ b/subprojects/extensions-app/js/main.js @@ -476,7 +476,7 @@ var ExtensionRow = GObject.registerClass({ function initEnvironment() { // Monkey-patch in a "global" object that fakes some Shell utilities // that ExtensionUtils depends on. - window.global = { + globalThis.global = { log(...args) { print(args.join(', ')); },