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

Port V1 deps shortucts for tech and elems to V2 tech #469

Merged
merged 2 commits into from
Oct 16, 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
21 changes: 15 additions & 6 deletions lib/techs/v2/deps.js.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,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 Expand Up @@ -490,12 +495,16 @@ var DepsItem = exports.DepsItem = INHERIT({

extendByCtx: function(ctx) {
if(ctx && (ctx = ctx.item)) {
var ks = ['tech', 'block', 'elem', 'mod', 'val'],
k;
var keys = ['block', 'elem', 'mod', 'val'],
key;

while(k = ks.shift())
if(this.item[k]) break;
else ctx[k] && (this.item[k] = ctx[k]);
if (!this.item.tech && ctx.tech) {
this.item.tech = ctx.tech;
}
while (key = keys.shift()) {
if(this.item[key]) break;
else ctx[key] && (this.item[key] = ctx[key]);
}
}
return this;
},
Expand Down
6 changes: 2 additions & 4 deletions test/v2-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ describe('Deps', function() {
] } }
));

// TODO: https://github.com/bem/bem-tools/issues/401
it.skip('block with elem array', assertDepsParse(
it('block with elem array', assertDepsParse(
[ { block: 'b1', elem: ['e1', 'e2'] } ],
{ '': {'': [
{block: 'b1', elem: 'e1'},
Expand Down Expand Up @@ -151,8 +150,7 @@ describe('Deps', function() {
} }
));

// TODO: https://github.com/bem/bem-tools/issues/413
it.skip('block with tech shortcut', assertDepsParse(
it('block with tech shortcut', assertDepsParse(
{block: 'b1', tech: 't1', shouldDeps: {tech: 't2'}},
{ 't1': {
't1': [ { block: 'b1', tech: 't1'} ],
Expand Down