@bem.decl: normalize declaration

node v10.16.3
version: 1.0.2
endpointsharetweet
const bemDecl = require('@bem/sdk.decl'); const decl1 = [ { block: 'a'}, { block: 'b', elem: '1'}, { block: 'c', mod: 'beta'}, { block: 'd', elem: '1', mod: 'beta'} ]; bemDecl.normalize(decl1);
Get the IDs of the created BEM cells.
bemDecl.normalize(decl1).map(c => c.id);
Pass another declaration with a syntactic sugar.
const decl2 = [ { block: 'a'}, { block: 'b', elems: ['1', '2']}, { block: 'c', mods: ['green', 'yellow']}, { block: 'd', mods: { ver: ['alpha', 'beta']}} ]; bemDecl.normalize(decl2).map(c => c.id);
Pass declaration in "v1" format.
const decl_v1 = [ { name: 'a'}, { name: 'b', elems: [{ name: '1'}, { name: '2'}]} ]; bemDecl.normalize(decl_v1, { format: 'v1'}).map(c => c.id);
Loading…

no comments

    sign in to comment