Skip to content

Commit 7f6dcbc

Browse files
committed
wasm-bindgen: Added support for Internet Explorer 11
1 parent 33b859b commit 7f6dcbc

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/wasm32_bindgen.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ fn getrandom_init() -> Result<RngSource, Error> {
6464
// `crypto.getRandomValues`, but if `crypto` isn't defined we assume
6565
// we're in an older web browser and the OS RNG isn't available.
6666

67-
let crypto = self_.crypto();
67+
let mut crypto = self_.crypto();
6868
if crypto.is_undefined() {
69-
return Err(BINDGEN_CRYPTO_UNDEF);
69+
// If crypto is undefined, we can also check if msCrypto is defined,
70+
// in case it's Internet Explorer
71+
crypto = self_.ms_crypto();
72+
73+
if crypto.is_undefined() {
74+
return Err(BINDGEN_CRYPTO_UNDEF);
75+
}
7076
}
7177

7278
// Test if `crypto.getRandomValues` is undefined as well
@@ -88,6 +94,11 @@ extern "C" {
8894
fn get_self() -> Result<Self_, JsValue>;
8995

9096
type Self_;
97+
98+
// Internet Explorer 11
99+
#[wasm_bindgen(method, getter, js_name="msCrypto", structural)]
100+
fn ms_crypto(me: &Self_) -> JsValue;
101+
91102
#[wasm_bindgen(method, getter, structural)]
92103
fn crypto(me: &Self_) -> JsValue;
93104

0 commit comments

Comments
 (0)