For avoid copy-paste of [{ block: 'b1' }].concat(this.ctx.mix) we can introduce two new helpers: for construct or convert to array with adding argument after and for inplace modification of mix field.
function addTo(arr, item) {
if(typeof arr === 'undefined') arr = [];
else if(!Array.isArray(arr)) arr = [arr];
var i = 1;
while(item = arguments[i++]) arr.push(item);
return arr
}
function addMixTo(obj, item) {
var args = Array.prototype.slice.call(arguments, 1);
args.unshift(obj.mix);
obj.mix = addTo(null, args);
return obj;
}
Also need to think about similar helpers for other fields (like js, attrs and so on).
For avoid copy-paste of
[{ block: 'b1' }].concat(this.ctx.mix)
we can introduce two new helpers: for construct or convert to array with adding argument after and for inplace modification ofmix
field.Also need to think about similar helpers for other fields (like
js
,attrs
and so on).See https://github.com/bem/bem-core/issues/820 for details