diff options
Diffstat (limited to 'src/shared/styling.ts')
| -rw-r--r-- | src/shared/styling.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/shared/styling.ts b/src/shared/styling.ts index 759fecb..57a39f6 100644 --- a/src/shared/styling.ts +++ b/src/shared/styling.ts @@ -1,9 +1,16 @@ -export function styles(selector: string, styles: Record<string, string>) { - const elements = Array.from(document.querySelectorAll(selector)) as HTMLElement[]; +/** + * Applies a set of inline CSS styles to every element matching the + * given CSS selector. + * + * @param selector - CSS selector string. + * @param styles - A map of CSS property names to values. + */ +export function styles(selector: string, styles: Record<string, string>): void { + const elements = Array.from(document.querySelectorAll(selector)); for (const element of elements) { for (const styleType in styles) { - element.style[styleType as any] = styles[styleType]; + (element as HTMLElement).style.setProperty(styleType, styles[styleType]); } } }; |
