Browse Source

Add removeAttributes method to Component

pull/3264/head
Artur Arseniev 5 years ago
parent
commit
8b952bb9d6
  1. 16
      src/dom_components/model/Component.js

16
src/dom_components/model/Component.js

@ -430,6 +430,22 @@ const Component = Backbone.Model.extend(Styleable).extend(
); );
}, },
/**
* Remove attributes from the component
* @param {String|Array<String>} attrs Array of attributes to remove
* @param {Object} options Options for the model update
* @return {this}
* @example
* component.removeAttributes('some-attr');
* component.removeAttributes(['some-attr1', 'some-attr2']);
*/
removeAttributes(attrs = [], opts = {}) {
const attrArr = Array.isArray(attrs) ? attrs : [attrs];
const compAttr = this.getAttributes();
attrArr.map(i => delete compAttr[i]);
return this.setAttributes(compAttr, opts);
},
/** /**
* Get the style of the component * Get the style of the component
* @return {Object} * @return {Object}

Loading…
Cancel
Save