Skip to content

Releases: bem-sdk-archive/bem-naming

v1.0.1

06 Jun 18:20
Compare
Choose a tag to compare

Bug fixes

  • Functions not working without context (#91).

    Example:

    var stringifyEntity = require('bem-naming').stringify;
    
    stringifyEntity({ block: 'button', modName: 'size', modVal: 's' });
    
    // Uncaught TypeError: Cannot read property 'modDelim' of undefined

v1.0.0

06 Jun 18:19
Compare
Choose a tag to compare

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-dashesHarry 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.
  • this was used instead of global object. (#86).

Removed deprecated

  • The BEMNaming filed removed (#74).

    Use bemNaming function to create custom naming:

    var bemNaming = require('bemNaming');
    
    var myNaming = bemNaming({ elem: '__', mod: '--' });
  • The elemSeparator, modSeparator and literal options removed (#75).

    Use elem, mod and wordPattern instead.

  • The bem-naming.min.js file removed.

Other

  • The stringify method should return undefined for 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) {
        /* ... */
    }

v0.5.1

06 Jun 18:18
Compare
Choose a tag to compare
  • Implemented caching for BEMNaming instances (#53).
  • stringify method is speeded up by 2,5 times (#57).
  • parse method is speeded up on 15% (#58).
  • typeOf method is speeded up by 2,25 times (#59).