fractal-core
Version:
A minimalist and well crafted app, content or component is our conviction
29 lines • 888 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const forOwn = require("lodash.forown");
const remove = require("lodash.remove");
const uniq = require("lodash.uniq");
// data.class
module.exports = function classModule(vnode, attributes) {
var values;
var _add = [];
var _remove = [];
var classes = vnode.data.class || {};
var existing = attributes.get('class');
existing = existing.length > 0 ? existing.split(' ') : [];
forOwn(classes, function (value, key) {
if (value === true) {
_add.push(key);
}
else {
_remove.push(key);
}
});
values = remove(uniq(existing.concat(_add)), function (value) {
return _remove.indexOf(value) < 0;
});
if (values.length) {
attributes.set('class', values.join(' '));
}
};
//# sourceMappingURL=class.js.map