Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
@bem.decl: normalize declaration
node v10.24.1
version:
1.0.2
endpoint
share
tweet
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