diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index 779e6cba7..1f6834449 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -121,7 +121,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({ initialize(props = {}, opt = {}) { - const em = opt.sm || opt.em || {}; + const em = opt.sm || opt.em || ''; // Propagate properties from parent if indicated const parent = this.parent(); @@ -189,7 +189,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({ getStyle() { const em = this.em; - if (em.getConfig('avoidInlineStyle')) { + if (em && em.getConfig('avoidInlineStyle')) { const state = this.get('state'); const cc = em.get('CssComposer'); const rule = cc.getIdRule(this.getId(), { state }); @@ -207,7 +207,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({ setStyle(prop = {}, opts = {}) { const em = this.em; - if (em.getConfig('avoidInlineStyle')) { + if (em && em.getConfig('avoidInlineStyle')) { prop = Styleable.setStyle.call(this, prop, {silent: 1, avoidStore: 1}); const state = this.get('state'); const cc = em.get('CssComposer'); @@ -501,7 +501,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({ this.opt.collection = null; } - if (em.getConfig('avoidInlineStyle') && !isEmpty(style)) { + if (em && em.getConfig('avoidInlineStyle') && !isEmpty(style)) { attr.style = style; } diff --git a/test/specs/code_manager/model/CodeModels.js b/test/specs/code_manager/model/CodeModels.js index 92b0692ca..636a30bf2 100644 --- a/test/specs/code_manager/model/CodeModels.js +++ b/test/specs/code_manager/model/CodeModels.js @@ -15,9 +15,11 @@ module.exports = { describe('HtmlGenerator', () => { beforeEach(() => { + em = new Editor(); obj = new HtmlGenerator(); dcomp = new DomComponents(); comp = new Component({}, { + em, componentTypes: dcomp.componentTypes, }); }); diff --git a/test/specs/dom_components/index.js b/test/specs/dom_components/index.js index cdae7b0ff..5cab2699b 100644 --- a/test/specs/dom_components/index.js +++ b/test/specs/dom_components/index.js @@ -5,12 +5,14 @@ const ComponentView = require('./view/ComponentV'); const ComponentsView = require('./view/ComponentsView'); const ComponentTextView = require('./view/ComponentTextView'); const ComponentImageView = require('./view/ComponentImageView'); +const Editor = require('editor/model/Editor'); const utils = require('./../test_utils.js'); describe('DOM Components', () => { describe('Main', () => { + var em; var obj; var config; var storagMock = utils.storageMock(); @@ -39,7 +41,9 @@ describe('DOM Components', () => { beforeEach(() => { + em = new Editor(); config = { + em, storeWrapper: 1, }; obj = new DomComponents().init(config);