I am using knockout.js components where Laravel passes configuration information.
The knockout code lists the default options and combines them with laravel options using ES2015 (new Javascript), for example:
this.options = {}; const defaults = { option1: true, option2: false, option3: true }; Object.assign(this.options,defaults,data.options);
Where data.options are the options specified in Laravel Blade
Object.assign works fine except <= IE9
So I need to insert the 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 like to kill this old code, but still support IE9 using the following Babel Babel transform:
https://www.npmjs.com/package/babel-plugin-transform-object-assign
However, Laravel Elixir does not have babel.rc configuration, so I cannot get this conversion to work.
Help rate!
source share