Skip to content

Commit 97ae91e

Browse files
committed
allow parent to be global/globalThis
Not tested on Node, but this should make it possible to run.
1 parent 323d9c8 commit 97ae91e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

js/unpickler.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,14 @@ export function loadclass(module_and_name) {
350350
if (module_and_name.indexOf(main_check) === 0) {
351351
module_and_name = module_and_name.slice(main_check.length);
352352
}
353-
let parent = window;
353+
let parent;
354+
if (typeof globalThis !== 'undefined') {
355+
parent = globalThis;
356+
} else if (typeof window !== 'undefined') {
357+
parent = window;
358+
} else if (typeof global !== 'undefined') {
359+
parent = global;
360+
}
354361
const module_class_split = module_and_name.split('.');
355362
for (let i = 0; i < module_class_split.length; i++) {
356363
const this_module_or_class = module_class_split[i];

0 commit comments

Comments
 (0)