bem-naming
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -71,12 +71,12 @@ (function (global) { | ||
var hasModVal = obj.hasOwnProperty('modVal'), | ||
isMod = obj.modName && (!hasModVal || obj.modVal); | ||
var modName = obj.modName, | ||
isMod = modName && (obj.modVal || !obj.hasOwnProperty('modVal')); | ||
if (obj.elem) { | ||
if (isMod) return TYPES.ELEM_MOD; | ||
if (!hasModVal) return TYPES.ELEM; | ||
if (!modName) return TYPES.ELEM; | ||
} | ||
if (isMod) return TYPES.BLOCK_MOD; | ||
if (!hasModVal) return TYPES.BLOCK; | ||
if (!modName) return TYPES.BLOCK; | ||
}; | ||
@@ -135,16 +135,17 @@ | ||
var elem = executed[5], | ||
modName = executed[2] || executed[6], | ||
modVal = executed[3] || executed[7], | ||
notation = {}; | ||
var notation = { | ||
block: executed[1] || executed[4] | ||
}, | ||
elem = executed[5], | ||
modName = executed[2] || executed[6]; | ||
if (modName && (modVal === undefined)) { | ||
modVal = true; | ||
elem && (notation.elem = elem); | ||
if (modName) { | ||
var modVal = executed[3] || executed[7]; | ||
notation.modName = modName; | ||
notation.modVal = modVal || true; | ||
} | ||
notation.block = executed[1] || executed[4]; | ||
elem && (notation.elem = elem); | ||
modName && (notation.modName = modName); | ||
modVal && (notation.modVal = modVal); | ||
return notation; | ||
@@ -164,6 +165,6 @@ }; | ||
var buf = [obj.block]; | ||
var res = obj.block; | ||
if (obj.elem) { | ||
buf.push(this.elemDelim + obj.elem); | ||
res += this.elemDelim + obj.elem; | ||
} | ||
@@ -175,11 +176,11 @@ | ||
if (modVal || modVal === 0 || !obj.hasOwnProperty('modVal')) { | ||
buf.push(this.modDelim + obj.modName); | ||
res += this.modDelim + obj.modName; | ||
} | ||
if (modVal && modVal !== true) { | ||
buf.push(this.modDelim + modVal); | ||
res += this.modDelim + modVal; | ||
} | ||
} | ||
return buf.join(''); | ||
return res; | ||
}; | ||
@@ -191,13 +192,25 @@ | ||
elem = '(?:' + this.elemDelim + '(' + word + '))?', | ||
mod = '(?:' + this.modDelim + '(' + word + '))?'; | ||
modPart = '(?:' + this.modDelim + '(' + word + '))?', | ||
mod = modPart + modPart; | ||
this._regex = new RegExp(['^', block, mod, mod, '$|^', block, elem, mod, mod, '$'].join('')); | ||
this._regex = new RegExp('^' + block + mod + '$|^' + block + elem + mod + '$'); | ||
}; | ||
var defineAsGlobal = true, | ||
originalNaming = new BEMNaming(), | ||
cache = {}, | ||
bemNaming = function (options) { | ||
return new BEMNaming(options); | ||
}; | ||
options || (options = {}); | ||
var naming = { | ||
elem: options.elem || options.elemSeparator || '__', | ||
mod: options.mod || options.modSeparator || '_', | ||
wordPattern: options.wordPattern || options.literal && (options.literal + '+') || | ||
'[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*' | ||
}, | ||
id = JSON.stringify(naming); | ||
return cache[id] || (cache[id] = new BEMNaming(naming)); | ||
}, | ||
originalNaming = bemNaming(); | ||
bemNaming.BEMNaming = BEMNaming; | ||
@@ -204,0 +217,0 @@ bemNaming.validate = function () { return originalNaming.validate.apply(originalNaming, arguments); }; |
{ | ||
"name": "bem-naming", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Manage naming of BEM entities", | ||
"keywords": [ | ||
"bem", | ||
"naming" | ||
"naming", | ||
"entities", | ||
"parse", | ||
"stringify" | ||
], | ||
@@ -19,8 +22,12 @@ "author": "Andrew Abramov <andrewblond@yandex.com>", | ||
"bugs": "https://github.com/bem/bem-naming/issues", | ||
"contributors": [ | ||
"maintainers": [ | ||
{ | ||
"name": "Andrew Abramov", | ||
"email": "andrewblond@yandex.com" | ||
"email": "andrewblond@yandex.com", | ||
"github-username": "andrewblond" | ||
} | ||
], | ||
"contributors": [ | ||
"Andrew Abramov <andrewblond@yandex.com>" | ||
], | ||
"engines": { | ||
@@ -36,17 +43,21 @@ "node": ">= 0.10.0" | ||
"istanbul": "0.3.5", | ||
"jscs": "1.8.1", | ||
"jscs": "1.9.0", | ||
"jshint": "2.5.11", | ||
"mocha": "2.0.1", | ||
"should": "4.4.1", | ||
"matcha": "0.6.0", | ||
"mocha": "2.1.0", | ||
"should": "4.5.0", | ||
"uglify-js": "2.4.16", | ||
"zuul": "1.16.0" | ||
"zuul": "1.16.4" | ||
}, | ||
"scripts": { | ||
"test": "npm run lint && npm run cover && npm run browser-test", | ||
"test": "npm run lint && npm run unit && npm run browser", | ||
"lint": "jshint . && jscs -c .jscs.js .", | ||
"node-test": "mocha ./test/**/*.test.js", | ||
"browser-test": "zuul -- ./test/**/*.test.js", | ||
"unit": "mocha ./test/**/*.test.js", | ||
"browser": "zuul -- ./test/**/*.test.js", | ||
"cover": "istanbul cover _mocha -- ./test/**/*.test.js", | ||
"min": "uglifyjs lib/bem-naming.js > bem-naming.min.js" | ||
"bench": "matcha benchmark/*.js", | ||
"min": "uglifyjs lib/bem-naming.js > bem-naming.min.js", | ||
"coveralls": "npm i coveralls && npm run cover && cat ./coverage/lcov.info | coveralls", | ||
"travis": "npm run test && npm run coveralls" | ||
} | ||
} |
bem-naming | ||
========== | ||
[![NPM version](http://img.shields.io/npm/v/bem-naming.svg?style=flat)](http://www.npmjs.org/package/bem-naming) [![Download](http://img.shields.io/badge/download-1%20kB-blue.svg?style=flat)](https://github.com/bem/bem-naming/releases/v0.5.0) [![Build Status](http://img.shields.io/travis/bem/bem-naming/master.svg?style=flat)](https://travis-ci.org/bem/bem-naming) [![Coverage Status](https://img.shields.io/coveralls/bem/bem-naming.svg?branch=master&style=flat)](https://coveralls.io/r/bem/bem-naming) [![devDependency Status](http://img.shields.io/david/dev/bem/bem-naming.svg?style=flat)](https://david-dm.org/bem/bem-naming#info=devDependencies) | ||
[![NPM version](http://img.shields.io/npm/v/bem-naming.svg?style=flat)](http://www.npmjs.org/package/bem-naming) [![Download](http://img.shields.io/badge/download-1%20kB-blue.svg?style=flat)](https://github.com/bem/bem-naming/releases/v0.5.1) [![Build Status](http://img.shields.io/travis/bem/bem-naming/master.svg?style=flat)](https://travis-ci.org/bem/bem-naming) [![Coverage Status](https://img.shields.io/coveralls/bem/bem-naming.svg?branch=master&style=flat)](https://coveralls.io/r/bem/bem-naming) [![devDependency Status](http://img.shields.io/david/dev/bem/bem-naming.svg?style=flat)](https://david-dm.org/bem/bem-naming#info=devDependencies) | ||
@@ -6,0 +6,0 @@ About |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36034
5
207
8