Archived
1
0
Fork 0

allow single string in class names attribute

This commit is contained in:
Dmitriy Pleshevskiy 2022-05-22 12:47:24 +03:00
parent 6e2a2e5c76
commit f1d6a2e989

View file

@ -1,7 +1,7 @@
import { Attrs } from "../core/node.ts";
import { isNotSkip, join, Skipable } from "../core/utils.ts";
import { isNotSkip, isStr, join, Skipable } from "../core/utils.ts";
export function classNames(vals: Skipable<string>[]): Attrs {
const val = join(" ", vals.filter(isNotSkip));
export function classNames(vals: string | Skipable<string>[]): Attrs {
const val = isStr(vals) ? vals : join(" ", vals.filter(isNotSkip));
return !val.length ? {} : { class: val };
}