(...args)
| 13 | } |
| 14 | |
| 15 | export function classNames(...args) { |
| 16 | if (isEmpty(args)) return; |
| 17 | const classList: string[] = []; |
| 18 | for (const arg of args) { |
| 19 | if (!arg) continue; |
| 20 | const argType = typeof arg; |
| 21 | if (argType === 'string' || argType === 'number') { |
| 22 | classList.push(`${arg}`); |
| 23 | continue; |
| 24 | } |
| 25 | if (argType === 'object') { |
| 26 | if (arg.toString !== Object.prototype.toString) { |
| 27 | classList.push(arg.toString()); |
| 28 | continue; |
| 29 | } |
| 30 | for (const key in arg) { |
| 31 | if (Object.hasOwnProperty.call(arg, key) && arg[key]) { |
| 32 | classList.push(key); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | return classList.join(' '); |
| 38 | } |
| 39 | /** |
| 40 | * Element names may consist of Latin letters, digits, dashes and underscores. |
| 41 | * CSS class is formed as block name plus two underscores plus element name: .block__elem |
no outgoing calls
no test coverage detected