Skip to content

Commit

Permalink
Fix mods whem elem as string given
Browse files Browse the repository at this point in the history
fixup: mod context to elem if given
  • Loading branch information
skad0 committed Aug 16, 2016
1 parent 7f968aa commit 2c2c1b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 5 additions & 2 deletions lib/normalize2.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ module.exports = function (decl) {
if (!isNotActual(mod)) {
processMods({ block, elem: elItem, mods: mod, tech });
}
if (!isNotActual(mods)) {
processMods({ block, elem: elItem, mods, tech });
}
} else {
const elemNames = Array.isArray(elItem.elem) ? elItem.elem : [elItem.elem];
const modsExists = !isNotActual(elItem.mods);
Expand All @@ -76,11 +79,11 @@ module.exports = function (decl) {
}
}

if (!isNotActual(mod) && elems) {
if (!isNotActual(mod) && elems && !elem) {
processMods({ block, mods: mod, tech });
}

if (!isNotActual(mods)) {
if (!isNotActual(mods) && !elem) {
processMods({ block, mods: mods, tech });
}

Expand Down
4 changes: 2 additions & 2 deletions test/normalize2/block-mods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ test('should pass mods to elem', t => {

t.deepEqual(normalize(decl), [
{ entity: { block: 'block', elem: 'elem' }, tech: undefined },
{ entity: { block: 'block', modName: 'm1', modVal: true }, tech: undefined },
{ entity: { block: 'block', modName: 'm1', modVal: 'v1' }, tech: undefined }
{ entity: { block: 'block', elem: 'elem', modName: 'm1', modVal: true }, tech: undefined },
{ entity: { block: 'block', elem: 'elem', modName: 'm1', modVal: 'v1' }, tech: undefined }
]);
});

Expand Down
6 changes: 2 additions & 4 deletions test/normalize2/unusual.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ test('should support both mod, mods, elem and elems :\'(', t => {
{ entity: { block: 'block', elem: 'elem1' }, tech: undefined },
{ entity: { block: 'block', elem: 'elem1', modName: 'mod1', modVal: true }, tech: undefined },
{ entity: { block: 'block', elem: 'elem1', modName: 'mod1', modVal: 'v1' }, tech: undefined },
{ entity: { block: 'block', modName: 'mod1', modVal: true }, tech: undefined },
{ entity: { block: 'block', modName: 'mod1', modVal: 'v1' }, tech: undefined },
{ entity: { block: 'block', modName: 'mod2', modVal: true }, tech: undefined },
{ entity: { block: 'block', modName: 'mod2', modVal: 'v2' }, tech: undefined },
{ entity: { block: 'block', elem: 'elem1', modName: 'mod2', modVal: true }, tech: undefined },
{ entity: { block: 'block', elem: 'elem1', modName: 'mod2', modVal: 'v2' }, tech: undefined },
{ entity: { block: 'block', elem: 'elem2' }, tech: undefined }
]);
});

0 comments on commit 2c2c1b6

Please sign in to comment.