diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index a2c2df471d..368a16c566 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -206,7 +206,7 @@ const Component = Backbone.Model.extend(Styleable).extend( if (!opt.temporary) { this.init(); - this.__isSymbol() && this.__initSymb(); + this.__isSymbolOrInst() && this.__initSymb(); em && em.trigger('component:create', this); } }, @@ -619,9 +619,13 @@ const Component = Backbone.Model.extend(Styleable).extend( return isArray(this.get(keySymbols)); }, + __isSymbolOrInst() { + return !!(this.__isSymbol() || this.get(keySymbol)); + }, + __isSymbolTop() { const parent = this.parent(); - const symb = this.__isSymbol() || this.__getSymbol(); + const symb = this.__isSymbolOrInst(); return ( symb && (!parent || (parent && !parent.__isSymbol() && !parent.__getSymbol())) @@ -666,7 +670,6 @@ const Component = Backbone.Model.extend(Styleable).extend( const { fromInstance } = opts; const symbols = this.__getSymbols() || []; const symbol = this.__getSymbol(); - !symbols.filter && console.log('!symbols.filter', symbols); let result = symbol && !fromInstance ? [symbol] diff --git a/src/dom_components/model/Components.js b/src/dom_components/model/Components.js index 8e9b6ea47b..7d9e37f4d9 100644 --- a/src/dom_components/model/Components.js +++ b/src/dom_components/model/Components.js @@ -258,28 +258,30 @@ export default Backbone.Collection.extend({ }, __onAddEnd: debounce(function() { - const { domc } = this; - const allComp = (domc && domc.allById()) || {}; - const firstAdd = this.__firstAdd; - const toCheck = isArray(firstAdd) ? firstAdd : [firstAdd]; - const silent = { silent: true }; - const onAll = comps => { - comps.forEach(comp => { - const symbol = comp.get(keySymbols); - const symbolOf = comp.get(keySymbol); - if (symbol && isArray(symbol) && isString(symbol[0])) { - comp.set( - keySymbols, - symbol.map(smb => allComp[smb]).filter(i => i), - silent - ); - } - if (isString(symbolOf)) { - comp.set(keySymbol, allComp[symbolOf], silent); - } - onAll(comp.components()); - }); - }; - onAll(toCheck); + // TODO to check symbols on load, probably this might be removed as symbols + // are always recovered from the model + // const { domc } = this; + // const allComp = (domc && domc.allById()) || {}; + // const firstAdd = this.__firstAdd; + // const toCheck = isArray(firstAdd) ? firstAdd : [firstAdd]; + // const silent = { silent: true }; + // const onAll = comps => { + // comps.forEach(comp => { + // const symbol = comp.get(keySymbols); + // const symbolOf = comp.get(keySymbol); + // if (symbol && isArray(symbol) && isString(symbol[0])) { + // comp.set( + // keySymbols, + // symbol.map(smb => allComp[smb]).filter(i => i), + // silent + // ); + // } + // if (isString(symbolOf)) { + // comp.set(keySymbol, allComp[symbolOf], silent); + // } + // onAll(comp.components()); + // }); + // }; + // onAll(toCheck); }) }); diff --git a/test/specs/dom_components/model/Symbols.js b/test/specs/dom_components/model/Symbols.js index 28a727d7a9..9a2e5e3839 100644 --- a/test/specs/dom_components/model/Symbols.js +++ b/test/specs/dom_components/model/Symbols.js @@ -14,6 +14,10 @@ describe('Symbols', () => { comp.parent().append(cloned, { at: comp.index() + 1 }); return cloned; }; + const simpleCompDef = { + type: 'text', + components: [{ type: 'textnode', content: 'Component' }] + }; const simpleComp = '