diff --git a/frontend/src/ts/utils/dom.ts b/frontend/src/ts/utils/dom.ts index 9b0d56263..e63f05b98 100644 --- a/frontend/src/ts/utils/dom.ts +++ b/frontend/src/ts/utils/dom.ts @@ -91,12 +91,18 @@ export function createElementWithUtils( tagName: string, options?: { classList?: string[]; + dataset?: Record; }, ): ElementWithUtils { const element = document.createElement(tagName) as T; if (options?.classList !== undefined) { element.classList.add(...options.classList); } + if (options?.dataset !== undefined) { + for (const key of Object.keys(options.dataset)) { + element.dataset[key] = options.dataset[key]; + } + } return new ElementWithUtils(element); }