You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
730 B
31 lines
730 B
10 years ago
|
function classNames() {
|
||
|
var classes = '';
|
||
|
var arg;
|
||
|
|
||
|
for (var i = 0; i < arguments.length; i++) {
|
||
|
arg = arguments[i];
|
||
|
if (!arg) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if ('string' === typeof arg || 'number' === typeof arg) {
|
||
|
classes += ' ' + arg;
|
||
|
} else if (Object.prototype.toString.call(arg) === '[object Array]') {
|
||
|
classes += ' ' + classNames.apply(null, arg);
|
||
|
} else if ('object' === typeof arg) {
|
||
|
for (var key in arg) {
|
||
|
if (!arg.hasOwnProperty(key) || !arg[key]) {
|
||
|
continue;
|
||
|
}
|
||
|
classes += ' ' + key;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return classes.substr(1);
|
||
|
}
|
||
|
|
||
|
// safely export classNames in case the script is included directly on a page
|
||
|
if (typeof module !== 'undefined' && module.exports) {
|
||
|
module.exports = classNames;
|
||
|
}
|