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

Add deps shortcut for depending on multiple elems #444

Merged
merged 1 commit into from
Sep 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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