(el: Element, updates: Record<string, string | null>)
| 208 | } |
| 209 | |
| 210 | export function setElementStyles(el: Element, updates: Record<string, string | null>): void { |
| 211 | const current = getElementStyles(el); |
| 212 | for (const [prop, value] of Object.entries(updates)) { |
| 213 | // Stored map is keyed camelCase (parseStyleAttr); custom props (--foo) stay |
| 214 | // verbatim. Normalize the incoming key the same way for both set and delete. |
| 215 | const key = toCamel(prop); |
| 216 | if (value === null) { |
| 217 | delete current[key]; |
| 218 | } else { |
| 219 | current[key] = value; |
| 220 | } |
| 221 | } |
| 222 | const serialized = serializeStyleAttr(current); |
| 223 | if (serialized) { |
| 224 | el.setAttribute("style", serialized); |
| 225 | } else { |
| 226 | el.removeAttribute("style"); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | // ─── Text helpers ───────────────────────────────────────────────────────────── |
| 231 |
no test coverage detected