Browse Source

Update trait init. Closes #4803

pull/4830/head
Artur Arseniev 4 years ago
parent
commit
7967881d21
  1. 4
      src/trait_manager/model/Trait.js

4
src/trait_manager/model/Trait.js

@ -12,7 +12,7 @@ import { Model } from '../../common';
*/
export default class Trait extends Model {
initialize() {
const { target, name, changeProp } = this.attributes;
const { target, name, changeProp, value: initValue } = this.attributes;
!this.get('id') && this.set('id', name);
if (target) {
@ -20,6 +20,8 @@ export default class Trait extends Model {
this.unset('target');
const targetEvent = changeProp ? `change:${name}` : `change:attributes:${name}`;
this.listenTo(target, targetEvent, this.targetUpdated);
const value = initValue || this.getValue();
!isUndefined(value) && this.set({ value }, { silent: true });
}
}

Loading…
Cancel
Save