class-prefixer
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -15,3 +15,3 @@ var classNames = require('classnames'); | ||
module.exports = function className(prefix) { | ||
function cls(mainClass, stateClass) { | ||
function cls(mainClass, stateClass, defaultPrefix) { | ||
mainClass = mainClass || ''; | ||
@@ -23,3 +23,4 @@ stateClass = stateClass || ''; | ||
.map(function(c) {return prefix + '-' + c}).join(' ') + ' ' + stateClass; | ||
return result.trim() || prefix; | ||
result = result.trim() || prefix; | ||
return (defaultPrefix && result !== prefix ) ? prefix + ' ' + result : result; | ||
} | ||
@@ -26,0 +27,0 @@ cls.add = function (name) { |
{ | ||
"name": "class-prefixer", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "clsssName prefixer", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -32,3 +32,9 @@ require('should'); | ||
cls('a').should.eql('pre-a'); | ||
}) | ||
}); | ||
it('defaultPrefix', function() { | ||
var cls = className('pre'); | ||
cls('a', '', true).should.eql('pre pre-a'); | ||
cls('', '', true).should.eql('pre'); | ||
cls('', 'a', true).should.eql('pre a'); | ||
}); | ||
}); |
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
4681
72