diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index 600dfd7e6c..3b119c73d8 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -113,9 +113,9 @@ module.exports = Backbone.Model.extend(Styleable).extend({ this.defaultCl = this.normalizeClasses(this.get('classes') || this.config.classes || []); this.components = new Components(this.defaultC, opt); this.components.parent = this; + this.set('attributes', this.get('attributes') || {}); this.listenTo(this, 'change:script', this.scriptUpdated); this.listenTo(this, 'change:traits', this.traitsUpdated); - this.set('attributes', this.get('attributes') || {}); this.set('components', this.components); this.set('classes', new Selectors(this.defaultCl)); var traits = new Traits(); diff --git a/src/trait_manager/model/Trait.js b/src/trait_manager/model/Trait.js index 4a28d2ad10..0f55687c74 100644 --- a/src/trait_manager/model/Trait.js +++ b/src/trait_manager/model/Trait.js @@ -23,8 +23,21 @@ module.exports = Backbone.Model.extend({ } }, + /** + * Get the initial value of the trait + * @return {string} + */ getInitValue() { - return this.get('value') || this.get('default'); + const target = this.target; + const name = this.get('name'); + let value; + + if (target) { + const attrs = target.get('attributes'); + value = this.get('changeProp') ? target.get(name) : attrs[name]; + } + + return value || this.get('value') || this.get('default'); } });