mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
12 lines
437 B
TypeScript
12 lines
437 B
TypeScript
import { kebabCase } from '../string/casing';
|
|
|
|
export function applyStyles(element: HTMLElement, styles: Record<string, string | undefined>): void {
|
|
for (const [prop, value] of Object.entries(styles)) {
|
|
if (typeof value === 'string') {
|
|
// CSS custom properties (--*) are already in the correct format.
|
|
const key = prop.startsWith('--') ? prop : kebabCase(prop);
|
|
element.style.setProperty(key, value);
|
|
}
|
|
}
|
|
}
|