From 6d82ac3970aa6365c6c9c7d5bafe16f238e8db08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Mon, 25 Feb 2019 11:45:42 +0200 Subject: [PATCH] Fix window.name being unset when loading include.js. Closes #1645 --- chrome/content/zotero/include.js | 13 ++++++++++++- resource/require.js | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/include.js b/chrome/content/zotero/include.js index fcb0858de6..17f1fe724e 100644 --- a/chrome/content/zotero/include.js +++ b/chrome/content/zotero/include.js @@ -9,7 +9,18 @@ var Zotero = Components.classes['@zotero.org/Zotero;1'] // Components.utils.import('resource://zotero/require.js'); // Not using Cu.import here since we don't want the require module to be cached -// for includes within ZoteroPane or other code, where we want the window instance available to modules. +// for includes within ZoteroPane or other code, where we want the window +// instance available to modules. +// However, doing this unsets `window.name` (and possibly other window props) +// so we're manually handling it here +var winName; +if (typeof window != 'undefined') { + winName = window.name; +} Components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getService(Components.interfaces.mozIJSSubScriptLoader) .loadSubScript('resource://zotero/require.js'); + +if (winName) { + window.name = winName; +} \ No newline at end of file diff --git a/resource/require.js b/resource/require.js index 103b16783d..5adf6b52c0 100644 --- a/resource/require.js +++ b/resource/require.js @@ -97,6 +97,6 @@ var require = (function() { }, globals }); - - return Require(loader, requirer); + let require = Require(loader, requirer); + return require })();