lib/filter/bem.js
function transformClassName(name, item, entityType) {
		var separators = getSeparators();
		var reSep = new RegExp('^(' + separators[entityType] + ')+', 'g');
		if (reSep.test(name)) {
			var depth = 0; // parent lookup depth
			var cleanName = name.replace(reSep, function(str) {
				depth = str.length / separators[entityType].length;
				return '';
			});
			
			// find donor element
			var donor = item;
			while (donor.parent && depth--) {
				donor = donor.parent;
			}
			
			if (!donor || !donor.__bem)
				donor = item;
			
			if (donor && donor.__bem) {
				var prefix = donor.__bem.block;
				
				// decide if we should inherit element name
//				if (entityType == 'element') {
//					var curElem = cleanName.split(separators.modifier, 1)[0];
//					if (donor.__bem.element && donor.__bem.element != curElem)
//						prefix += separators.element + donor.__bem.element;
//				}
				
				if (entityType == 'modifier' &&  donor.__bem.element)
					prefix += separators.element + donor.__bem.element;
				
				return prefix + separators[entityType] + cleanName;
			}
		}
		
		return name;
	}
function transformClassName(name, item, entityType) {
		var separators = getSeparators();
		var reSep = new RegExp('^(' + separators[entityType] + ')+', 'g');
		if (reSep.test(name)) {
			var depth = 0; // parent lookup depth
			var cleanName = name.replace(reSep, function(str) {
				depth = str.length / separators[entityType].length;
				return '';
			});
			
			// find donor element
			var donor = item;
			while (donor.parent && depth--) {
				donor = donor.parent;
			}
			
			if (!donor || !donor.__bem)
				donor = item;
			
			if (donor && donor.__bem) {
				var prefix = donor.__bem.block;
				
				// decide if we should inherit element name
//				if (entityType == 'element') {
//					var curElem = cleanName.split(separators.modifier, 1)[0];
//					if (donor.__bem.element && donor.__bem.element != curElem)
//						prefix += separators.element + donor.__bem.element;
//				}
				
				if (entityType == 'modifier' &&  donor.__bem.element)
					prefix += separators.element + donor.__bem.element;
				
				return prefix + separators[entityType] + cleanName;
			}
		}
		
		return name;
	}
function transformClassName ( name , item , entityType ) { var separators = getSeparators ( ) ; var reSep = new RegExp ( '^(' + separators [ entityType ] + ')+' , 'g' ) ; if ( reSep . test ( name ) ) { var depth = 0 ; // parent lookup depth var cleanName = name . replace ( reSep , function ( str ) { depth = str . length / separators [ entityType ] . length ; return '' ; } ) ; // find donor element var donor = item ; while ( donor . parent && depth -- ) { donor = donor . parent ; } if ( ! donor || ! donor . __bem ) donor = item ; if ( donor && donor . __bem ) { var prefix = donor . __bem . block ; // decide if we should inherit element name //				if (entityType == 'element') { //					var curElem = cleanName.split(separators.modifier, 1)[0]; //					if (donor.__bem.element && donor.__bem.element != curElem) //						prefix += separators.element + donor.__bem.element; //				} if ( entityType == 'modifier' && donor . __bem . element ) prefix += separators . element + donor . __bem . element ; return prefix + separators [ entityType ] + cleanName ; } } return name ; }
Low-level function to transform user-typed class name into full BEM class
@param {String} name Class name item to process
@param {AbbreviationNode} item Host node for provided class name
@param {String} entityType Type of entity to be tried to transform
('element' or 'modifier')
@returns {String} Processed class name or original one if it can't be
transformed
Low - level function to transform user - typed class name into full BEM class