(
tagName: string,
parent?: HTMLElement | null,
attributes: Record<string, string> = {},
text?: string,
)
| 32 | doc.getElementById(id) as HTMLElement; |
| 33 | |
| 34 | export const createElement = ( |
| 35 | tagName: string, |
| 36 | parent?: HTMLElement | null, |
| 37 | attributes: Record<string, string> = {}, |
| 38 | text?: string, |
| 39 | ): HTMLElement => { |
| 40 | const element = doc.createElement(tagName); |
| 41 | Object.entries(attributes).forEach((attribute) => |
| 42 | element.setAttribute(...attribute), |
| 43 | ); |
| 44 | if (text != null) { |
| 45 | element.innerText = text; |
| 46 | } |
| 47 | return parent != null ? parent.appendChild(element) : element; |
| 48 | }; |
| 49 | |
| 50 | export const addClass = (element: HTMLElement, add: string): void => |
| 51 | element.classList.add(add); |
no outgoing calls
no test coverage detected
searching dependent graphs…