1

Thing is someone told me that this "..." is not supported on Edge. There's something with the following code that has compatibility problems and the website is not showing up.

Here's the code:

    //<< Mapping  hash
    hash = {
        route: hash[0].split(/\//)[0],
        params: hash[0].split(/\//).slice(1),
        queryParams: hash.length > 1 ? hash[1] : "",
    }

    hash.queryParams = hash.queryParams?hash.queryParams.split(/&/).reduce((a, c, i) => {
        return {...a,...{[c.split(/=/)[0]]: c.split(/=/)[1]}}
    }, {}):{}; // I got to fix this (Reynald - 12: 35 pm)
    //>>

The problem is specially on the hash.queryParams = ....

I'm going to split the complete function with its property and every method used on it. I know I will get a larger way so Edge doesn't get any problem on reading the website.

hash.queryParams = hash.queryParams?hash.queryParams.split(/&/).reduce((a, c, i) => {
        return {...a,...{[c.split(/=/)[0]]: c.split(/=/)[1]}}
    }, {}):{}; // I got to fix this (Reynald - 12: 35 pm)```

Anything by the moment. The output is that the website should be rendered from an external file which has a JavaScript that is drawing the website on an index.html, what I mean is for example a main.js that is drawing at index.html and the main.js has connections to call every independent page with each corresponding file.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122

1 Answers1

0

Seems that spread operators are not supported in Edge for destructuring, so whoever told you that was correct. Unless you want to deal with transpiling your code, you can try using Object.assign().

Replace return {...a,...{[c.split(/=/)[0]]: c.split(/=/)[1]}} with something like:

return Object.assign(a, {[c.split(/=/)[0]]: c.split(/=/)[1]})
Chris B.
  • 5,477
  • 1
  • 12
  • 30
  • Thank you it worked! Now I got another problem, apparently with the following code: main.load = function (page) { function getClass(className) { return Function('return ' + className)(); } return new Promise((resolve, reject) => { try{ new getClass(page); // await && then / something like it... }catch{ script.src = `src/pages/${page}/${page}.js`; return; } resolve(getClass(page)); }); // ---> Next Commit. To convert this into an asyncronic calls an more .. } Specially with new g. – Reynald Ramirez de Luna Jun 05 '19 at 21:48
  • Glad it worked out! What is the specific problem? If you can format that and add it to your answer with what the issue is I will take a look – Chris B. Jun 05 '19 at 22:55
  • 1
    @ReynaldRamirezdeLuna if you have further questions, please ask a new question. – Heretic Monkey Jun 06 '19 at 13:50
  • Please @RutherfordWonkington follow this question here: [link](https://stackoverflow.com/questions/56479576/i-got-the-expected-script1005-with-javascript-on-edge-with-chrome-its-wor) – Reynald Ramirez de Luna Jun 06 '19 at 14:22