Use self instead of window

That should hopefully get us more compatible with web workers!

Closes #144
This commit is contained in:
Alex Crichton 2018-04-19 07:20:04 -07:00
parent 055a8fb803
commit 45e4983e8c

View File

@ -279,7 +279,7 @@ impl<'a> Context<'a> {
return; return;
}}); }});
}}; }};
window.wasm_bindgen = Object.assign(init, __exports); self.wasm_bindgen = Object.assign(init, __exports);
}})(); }})();
", ",
globals = self.globals, globals = self.globals,
@ -747,8 +747,8 @@ impl<'a> Context<'a> {
")); "));
} else if !(self.config.browser || self.config.no_modules) { } else if !(self.config.browser || self.config.no_modules) {
self.global(&format!(" self.global(&format!("
const TextEncoder = typeof window === 'object' && window.TextEncoder const TextEncoder = typeof self === 'object' && self.TextEncoder
? window.TextEncoder ? self.TextEncoder
: require('util').TextEncoder; : require('util').TextEncoder;
")); "));
} }
@ -767,8 +767,8 @@ impl<'a> Context<'a> {
")); "));
} else if !(self.config.browser || self.config.no_modules) { } else if !(self.config.browser || self.config.no_modules) {
self.global(&format!(" self.global(&format!("
const TextDecoder = typeof window === 'object' && window.TextDecoder const TextDecoder = typeof self === 'object' && self.TextDecoder
? window.TextDecoder ? self.TextDecoder
: require('util').TextDecoder; : require('util').TextDecoder;
")); "));
} }