Releases: bem-sdk-archive/bem-naming
v1.0.1
v1.0.0
Modifier Delimiters (#76)
Added support to separate value of modifier from name of modifier with specified string.
Before one could only specify a string to separate name of a modifier from name of a block or an element. It string used to separate value of modifier from name of modifier.
Before:
var myNaming = bemNaming({
mod: '--'
});
var obj = {
block: 'block',
modName: 'mod',
modVal: 'val'
};
myNaming.stringify(obj); // 'block--mod--val'Now:
var myNaming = bemNaming({
mod: { name: '--', val: '_' }
});
var obj = {
block: 'block',
modName: 'mod',
modVal: 'val'
};
myNaming.stringify(obj); // 'block--mod_val'Also added the modValDelim field.
Presets (#81)
Added naming presets:
origin(by default) — Yandex convention (block__elem_mod_val).two-dashes— Harry Roberts convention (block__elem--mod_val).
It is nessesary not to pass all options every time you use the convention by Harry Roberts.
var bemNaming = require('bem-naming');
// with preset
var myNaming = bemNaming('two-dashes');Bug fixes
-
Functions for custom naming not working without context(#72).
Example:
var bemNaming = require('bem-naming'); var myNaming = bemNaming({ mod: '--' }); ['block__elem', 'block--mod'].map(myNaming.parse); // The `parse` function requires context of `myNaming` object. // To correct work Usage of bind (myNaming.parse.bind(myNaming)) // was necessary.
-
thiswas used instead of global object. (#86).
Removed deprecated
-
The
BEMNamingfiled removed (#74).Use
bemNamingfunction to create custom naming:var bemNaming = require('bemNaming'); var myNaming = bemNaming({ elem: '__', mod: '--' });
-
The
elemSeparator,modSeparatorandliteraloptions removed (#75).Use
elem,modandwordPatterninstead. -
The
bem-naming.min.jsfile removed.
Other
-
The
stringifymethod should returnundefinedfor invalid objects, but not throw errror (#71).It will be easier to check for an empty string than use
try..catch.Before:
try { var str = bemNaming.stringify({ elem: 'elem' }); } catch(e) { /* ... */ }
Now:
var str = bemNaming.stringify({ elem: 'elem' }); if (str) { /* ... */ }