diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index b38f557c8..d28e3fb70 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -289,6 +289,17 @@ const Component = Backbone.Model.extend(Styleable).extend( this.set('attributes', attrs); }, + /** + * Add attributes to the model + * @param {Object} attrs Key value attributes + * @example + * model.addAttributes({id: 'test'}); + */ + addAttributes(attrs) { + const newAttrs = { ...this.getAttributes(), ...attrs }; + this.setAttributes(newAttrs); + }, + getStyle() { const em = this.em;