zelark / nano-id

A unique string ID generator for Clojure and ClojureScript (・_・)ノ
MIT License
191 stars 9 forks source link

Fix ReferenceError: “crypto” undefined, in IE11 #13

Closed Em-AK closed 3 years ago

Em-AK commented 4 years ago

Following advice documented on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Window/crypto

Maybe not the most elegant way to solve this. So feel free to edit, or ask me to do it. This is how I made it work for my app.

Em-AK commented 4 years ago

Actually this fix is not working in advanced compilation mode ...

zelark commented 4 years ago

Thanks for reporting and fixing. I'll look at it today.

zelark commented 4 years ago

@Em-AK I wouldn't want to put support for IE11 in the library itself. However, you can support it locally. This should help:

;; IE11 support
(when-not (exists? js/crypto)
  (set! js/crypto js/msCrypto))

Borrowed this solution from here. Just make sure that the code above has evaluated before nano-id is call.

Please, respond after checking it, I will put this example in the readme.

zelark commented 4 years ago

@Em-AK have you checked?

Em-AK commented 4 years ago

I'll come back to it in a week or two :beach_umbrella: