Skip to content
This repository has been archived by the owner on Jan 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #444 from bem/feature/multiple_elem_shortcut
Browse files Browse the repository at this point in the history
Add deps shortcut for depending on multiple elems
  • Loading branch information
scf2k committed Sep 11, 2013
2 parents 40d02ce + 5f1c28e commit 3223199
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/techs/deps.js.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ var Deps = exports.Deps = INHERIT({

var depsItem = new DepsItem(item, ctx);

fn.call(_this, depsItem); // _this.add(rootItem, 'shouldDeps', depsItem);
if (Array.isArray(item.elem)) {
//add only elems and not block
forEachItem('elem', item.elem, depsItem);
} else {
fn.call(_this, depsItem); // _this.add(rootItem, 'shouldDeps', depsItem);
}

_this.parse(
item.mustDeps,
Expand Down
17 changes: 17 additions & 0 deletions test/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ describe('Deps', function() {
{ '': { '': [ { block: 'b1' }, { block: 'b2' } ] } }
));

it('block with elems', assertDepsParse(
[ { block: 'b1', elems: [ 'e1', 'e2' ] } ],
{ '': { '': [
{block: 'b1'},
{block: 'b1', elem: 'e1'},
{block: 'b1', elem: 'e2'},
] } }
));

it('block with elem array', assertDepsParse(
[ { block: 'b1', elem: ['e1', 'e2'] } ],
{ '': {'': [
{block: 'b1', elem: 'e1'},
{block: 'b1', elem: 'e2'}
] } }
));

});

describe('new format with techs', function() {
Expand Down

0 comments on commit 3223199

Please sign in to comment.