Browse Source

Init symbols on load

pull/3165/head
Artur Arseniev 6 years ago
parent
commit
3a7506b0c1
  1. 13
      src/dom_components/model/Component.js

13
src/dom_components/model/Component.js

@ -192,6 +192,7 @@ const Component = Backbone.Model.extend(Styleable).extend(
this.listenTo(this, 'change:attributes:id', this._idUpdated); this.listenTo(this, 'change:attributes:id', this._idUpdated);
this.set('status', ''); this.set('status', '');
this.views = []; this.views = [];
this.__isSymbol() && this.__initSymb();
// Register global updates for collection properties // Register global updates for collection properties
['classes', 'traits', 'components'].forEach(name => { ['classes', 'traits', 'components'].forEach(name => {
@ -574,6 +575,16 @@ const Component = Backbone.Model.extend(Styleable).extend(
return classStr ? classStr.split(' ') : []; return classStr ? classStr.split(' ') : [];
}, },
__initSymb() {
if (this.__symbReady) return;
this.on('change', this.__upSymbProps);
this.__symbReady = 1;
},
__isSymbol() {
return isArray(this.get('__symbol'));
},
__getSymbToUp(opts = {}) { __getSymbToUp(opts = {}) {
const symbol = this.get('__symbol'); const symbol = this.get('__symbol');
const isMain = Array.isArray(symbol); const isMain = Array.isArray(symbol);
@ -993,7 +1004,7 @@ const Component = Backbone.Model.extend(Styleable).extend(
const symbols = this.get('__symbol') || []; const symbols = this.get('__symbol') || [];
symbols.push(cloned); symbols.push(cloned);
this.set('__symbol', symbols); this.set('__symbol', symbols);
this.on('change', this.__upSymbProps); this.__initSymb();
cloned.set('__symbol', this); cloned.set('__symbol', this);
} else { } else {
cloned.set('__symbol', 0); cloned.set('__symbol', 0);

Loading…
Cancel
Save