bem-sdk-archive / bemjson-to-decl

BEMJSON to BEMDECL converter. DEPRECATED →
https://github.com/bem/bem-sdk/tree/master/packages/bemjson-to-decl
Other
2 stars 2 forks source link

mods vs elemMods #25

Closed Yeti-or closed 7 years ago

Yeti-or commented 7 years ago

what about ignore mods on elems ?

https://runkit.com/581a9fba871f320014cdcdf7/58ae28aaef3db200148290ed

var bemjsonToDecl = require("bemjson-to-decl");

var bemJson1 = ({ 
    block: 'popup',
    elem: 'wtf',
    mods: { 'nope': true }
});

var bemJson2 = ({
    block: 'popup',
    elem: 'wtf',
    elemMods: { 'nope': true }
});

JSON.stringify(bemjsonToDecl.convert(bemJson1), null, 4)
===
JSON.stringify(bemjsonToDecl.convert(bemJson2), null, 4)

is true, but should be false

qfox commented 7 years ago

We should not ignore mods on elems, we should use them as block ones.

I'm not sure we should extract them:

{
    block: 'popup',
    elem: 'wtf',
    mods: { 'nope': true }
}

[ { block: 'popup' },
  { block: 'popup', elem: 'wtf' },
  { block: 'popup', mod: 'nope', val: true } ]

?

Yeti-or commented 7 years ago

this is elem

{
    block: 'popup',
    elem: 'wtf',
    mods: { 'nope': true }
}

and I think we should extract only it [ { block: 'popup', elem: 'wtf' } ]