coderello / laravel-shared-data

📦 An easy way to share the data from your backend to the JavaScript.
https://coderello.com/docs/laravel-shared-data/1.0/sharing-data
MIT License
321 stars 22 forks source link

IE compatibility #23

Closed yepzy closed 4 years ago

yepzy commented 4 years ago

I found that your package make webpages not working on IE 11.

And I found why, it's because in the function getJsHelper of the file src/SharedData.php, the JS code generated use a default parameter (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) in a function that is not compatible with IE.

Here is a correction that I tried and works well on IE.

window["'.$this->getJsHelperName().'"] = function(e) {
    var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
    return [window.sharedDataNamespace].concat("string" == typeof e ? e.split(".") : []).reduce(function(e, t) {
        return e === n || "object" != typeof e || void 0 === e[t] ? n : e[t]
    }, window)
}

Can I send you a pull request to make your package compatible with IE, or you want to do it yourself ?

hivokas commented 4 years ago

Hi @yepzy! It would be cool if you submit the PR!

hivokas commented 4 years ago

I've published the release!