Skip to content

Commit

Permalink
fix: camelToHyphen keys
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Dec 23, 2023
1 parent ac33f5b commit 1fce37f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 63 deletions.
6 changes: 5 additions & 1 deletion packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function cssObj2StrSync(style: Record<string, CSSObject>): string {

export function stringifyObj(obj: CSSObject) {
return `{${Object.keys(obj).reduce((str, key) => {
return `${str}${key}:${obj[key]};`
return `${str}${camelToHyphen(key)}:${obj[key]};`
}, '')}}`
}

Expand All @@ -141,3 +141,7 @@ export async function cssObj2StrAsync(style: Record<string, CSSObject>) {
export function toArray<T>(val: T | T[]): T[] {
return Array.isArray(val) ? val : [val]
}

export function camelToHyphen(str: string): string {
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();

Check failure on line 146 in packages/core/src/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
}
Loading

0 comments on commit 1fce37f

Please sign in to comment.