Jump to content
thirty bees forum

BUG: Version 3.3.5 throws a JS syntax error in IE 11


braffas

Recommended Posts

In modules\ganalytics\views\templates\hook\analyticsjs.tpl

  function uuidv4() {
    return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
      (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
    )
  }

This function throws a syntax error in IE 11 which in my case blocked customers from checking out on IE 11 (and probably lower versions also). TBH that function looks scary as hell, i have no idea how to fix it.

Link to comment
Share on other sites

That's because Uint8Array is not supported on ie and edge yet (and also es6 arrow function which is not supported on ie).

This function purpose is to generate pseudo-random uuid v4. It's safe to switch to another implementation:

``` function uuidv4() { var uuid = "", i, random; for (i = 0; i < 32; i++) { random = Math.random() * 16 | 0;

if (i == 8 || i == 12 || i == 16 || i == 20) {
  uuid += "-"
}
uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);

} return uuid; } ```

I've filed issue https://github.com/thirtybees/thirtybees/issues/584

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...