fix: make style util function work when a style only has true as value

This commit is contained in:
Xymorot 2019-10-12 03:48:36 +02:00
parent b71a15536d
commit 0bec8a8a76
1 changed files with 3 additions and 1 deletions

View File

@ -7,7 +7,9 @@ export function c(input: Array<string | boolean> | object): string {
export function s(styles: object): string {
return Object.keys(styles)
.filter((key: keyof object) => styles[key] === 0 || !!styles[key])
.filter(
(key: keyof object) => typeof styles[key] === 'number' || (typeof styles[key] === 'string' && !!styles[key])
)
.map((key: keyof object) => `${key}:${styles[key]}`)
.join(';');
}