GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.38k stars 4.06k forks source link

Issue with grapjs.init() #1604

Closed umairabid closed 5 years ago

umairabid commented 5 years ago

Apparently options passed to grapjs.init() are not being deep cloned and same object is being mutated which was originally passed. This is creating a weird issue, I cannot do this

this._builder = grapesjs.init({
            container : '#gjs',
            plugins: ['gjs-preset-newsletter'],
            pluginsOpts: myOptions
});

Mutation can be seen by logging myOptions before init and the result is very weird, editor without any components

screen shot 2018-11-26 at 10 15 55 am

I had to fix it using cloneDeep of lodash like

this._builder = grapesjs.init({
            container : '#gjs',
            plugins: ['gjs-preset-newsletter'],
            pluginsOpts: cloneDeep(myOptions)
});

My version is "grapesjs": "^0.14.43",

artf commented 5 years ago

The option object is passed to the plugin as it is and there is no reason to clone it

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.