Browse Source

Add options as second argument of model.addAttributes

pull/2977/head
Artur Arseniev 6 years ago
parent
commit
d3bc39b9f1
  1. 6
      src/dom_components/model/Component.js

6
src/dom_components/model/Component.js

@ -373,6 +373,7 @@ const Component = Backbone.Model.extend(Styleable).extend(
/**
* Update attributes of the component
* @param {Object} attrs Key value attributes
* @param {Object} options Options for the model update
* @return {this}
* @example
* component.setAttributes({ id: 'test', 'data-key': 'value' });
@ -385,13 +386,14 @@ const Component = Backbone.Model.extend(Styleable).extend(
/**
* Add attributes to the component
* @param {Object} attrs Key value attributes
* @param {Object} options Options for the model update
* @return {this}
* @example
* component.addAttributes({ 'data-key': 'value' });
*/
addAttributes(attrs) {
addAttributes(attrs, opts = {}) {
const newAttrs = { ...this.getAttributes(), ...attrs };
this.setAttributes(newAttrs);
this.setAttributes(newAttrs, opts);
return this;
},

Loading…
Cancel
Save