mirror of
https://github.com/zotero/zotero.git
synced 2026-10-05 02:43:38 +00:00
Give require()'d modules a window context
This commit is contained in:
parent
5ded9a84ee
commit
261b76d380
1 changed files with 13 additions and 0 deletions
|
|
@ -91,6 +91,10 @@ function ZoteroLoader({
|
|||
});
|
||||
|
||||
this.require = Require(this.loader, { id: "zotero" });
|
||||
|
||||
let win = typeof window !== "undefined" ? window : {};
|
||||
let doc = win.document ?? {};
|
||||
let navigator = typeof win.navigator !== 'undefined' ? win.navigator : {};
|
||||
|
||||
// Various globals are available from ESM, but not from sandboxes,
|
||||
// inject them into the globals list.
|
||||
|
|
@ -118,6 +122,15 @@ function ZoteroLoader({
|
|||
WebSocket,
|
||||
WindowGlobalChild,
|
||||
WindowGlobalParent,
|
||||
window: win,
|
||||
document: doc,
|
||||
navigator,
|
||||
setTimeout: win.setTimeout,
|
||||
clearTimeout: win.clearTimeout,
|
||||
setInterval: win.setInterval,
|
||||
clearInterval: win.clearInterval,
|
||||
requestAnimationFrame: win.requestAnimationFrame,
|
||||
cancelAnimationFrame: win.requestAnimationFrame,
|
||||
};
|
||||
for (const name in injectedGlobals) {
|
||||
this.loader.globals[name] = injectedGlobals[name];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue