Skip to content

Commit

Permalink
Fix broken css utility
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwep committed Nov 23, 2022
1 parent 7585eee commit c5e43d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vanilla/src/utils/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ const unitify = (val: string | number, unit = 'px'): string => {
*/
export function css(
{style}: HTMLElement,
attr: Partial<Record<string, string | number>> | string,
attr: Partial<Record<keyof CSSStyleDeclaration, string | number>> | string,
val?: string | number
): void {
if (typeof attr === 'object') {

for (const [key, value] of Object.entries(attr)) {
value !== undefined && style.setProperty(key, unitify(value));
value !== undefined && (style[key as any] = unitify(value));
}

} else if (val !== undefined) {
style.setProperty(attr, unitify(val));
style[attr as any] = unitify(val);
}
}

Expand Down

0 comments on commit c5e43d4

Please sign in to comment.