Skip to content

Commit

Permalink
Merge pull request #41 from bem/issue-34
Browse files Browse the repository at this point in the history
Added support for CamelCase
  • Loading branch information
Andrew Abramov committed Oct 29, 2014
2 parents ac0f763 + 5462f83 commit 1b44373
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/bem-naming.js
Expand Up @@ -6,8 +6,8 @@
* @param {Object} [options]
* @param {Object} [options.elem='__'] Separates element's name from block.
* @param {Object} [options.mod='_'] Separates names and values of modifiers from blocks and elements.
* @param {Object} [options.wordPattern='[a-z0-9]+(?:-[a-z0-9]+)*'] Defines which symbols can be used for block,
* element and modifier's names.
* @param {Object} [options.wordPattern='[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*] Defines which symbols can be used for block,
* element and modifier's names.
*
* @name BEMNaming
* @constructor
Expand All @@ -17,7 +17,8 @@ var BEMNaming = function (options) {

this._elemDelimiter = options.elem || options.elemSeparator || '__';
this._modDelimiter = options.mod || options.modSeparator || '_';
this._wordPattern = options.wordPattern || options.literal && (options.literal + '+') || '[a-z0-9]+(?:-[a-z0-9]+)*';
this._wordPattern = options.wordPattern || options.literal && (options.literal + '+') ||
'[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*';

this._buildRegex();
};
Expand Down
4 changes: 4 additions & 0 deletions test/harry-roberts/validate.test.js
Expand Up @@ -57,5 +57,9 @@ describe('harry roberts', function () {
it('should not validate block name with illegal literals', function () {
naming.validate('block_elem').should.be.false;
});

it('should support CamelCase', function () {
naming.validate('BlockName').should.be.true;
});
});
});
4 changes: 4 additions & 0 deletions test/original/validate.test.js
Expand Up @@ -57,5 +57,9 @@ describe('original', function () {
it('should not validate block name with illegal literals', function () {
naming.validate('^_^').should.be.false;
});

it('should support CamelCase', function () {
naming.validate('BlockName').should.be.true;
});
});
});

0 comments on commit 1b44373

Please sign in to comment.