Skip to content

Commit 254896b

Browse files
author
Andrii Kirmas
committed
Change wrapper to have undefined as classKeys
1 parent 31e2ff3 commit 254896b

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/basic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function _classNaming(
4242
const className = joinWithLead(propagate, dehash(classes))
4343
, host: ClassNamingCall = classes => _classNaming(classes, className)
4444

45-
return wrapper(className, [], host)
45+
return wrapper(className, undefined, host)
4646
}
4747

4848
type ClassNamingChain = ClassNamingCall & {

src/core.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ export {
1313
joinWithLead
1414
}
1515

16-
function wrapper<T>(className: Falsy|ClassValue, classKeys: string[], destination: T) {
16+
function wrapper<T>(
17+
className: Parameters<typeof joinWithLead>[0],
18+
classKeys: Parameters<typeof joinWithLead>[1],
19+
destination: T
20+
) {
1721
//@ts-expect-error
18-
destination[classNameKey] = joinWithLead(className, classKeys)
22+
destination[classNameKey]
23+
= joinWithLead(className, classKeys)
1924

2025
return stringifyClassNamed(destination as T & ClassNamed)
2126
}
@@ -53,13 +58,13 @@ function truthyKeys<T>(source: T) {
5358
return filtered
5459
}
5560

56-
//TODO Consider undefined
57-
function joinWithLead(value: Falsy|ClassValue, arr: readonly string[]) :string {
61+
//TODO Consider returning `undefined` on empty string
62+
function joinWithLead(value: Falsy|ClassValue, arr: undefined| readonly string[]) : string {
5863
const str1 = value || ""
59-
if (!arr.length)
64+
if (!(arr && arr.length))
6065
return str1
6166

62-
const str2 = arr.join(" ")
67+
const str2 = arr.join(" ")
6368
if (!str1)
6469
return str2
6570

0 commit comments

Comments
 (0)