I am using knockout.js components where Laravel passes configuration information.
The knockout code lists default options, and merges them with the laravel parameters, using ES2015 (new Javascript) e.g:
this.options = {};
const defaults = {
option1: true,
option2: false,
option3: true
};
Object.assign(this.options,defaults,data.options);
Where data.options are the options set in Laravel Blade
Object.assign works fine except <= IE9
So I have to insert code instead of Object.assign:
for (var key in defaults) {
if (data.options.hasOwnProperty(key)) {
this.options[key] = data.options[key];
} else {
this.options[key] = defaults[key];
}
}
I would love to kill this old code but still support IE9 using the following NPM Babel transform:
https://www.npmjs.com/package/babel-plugin-transform-object-assign
However Laravel Elixir appears to not have a babel.rc config, so I am unable to get this transform working.
Help appreciated!
gulpfile.js
? – Latrell