ha-frontend-cdce8p/js/common/util/attribute_class_names.js
Adam Mills 70c082716f MVP tests for hass-util.html (#629)
* MVP tests for hass-util.html

* MVP util.js to allow individual JS function export

* Use mocha to unit test js logic

* Isolate mocha test directory

* Move mocha opts to separate file

* Default export of util function

* Use reify for mocha tests instead of babel
2017-11-15 21:42:54 -08:00

7 lines
260 B
JavaScript

export default function attributeClassNames(stateObj, attributes) {
if (!stateObj) return '';
return attributes.map(function (attribute) {
return attribute in stateObj.attributes ? 'has-' + attribute : '';
}).filter(attr => attr !== '').join(' ');
}