refactor: share dom ready

This commit is contained in:
2026-06-01 22:25:47 +02:00
parent 36435b6eb5
commit 455490f07d
4 changed files with 13 additions and 26 deletions

View File

@@ -11,3 +11,12 @@ export const parseClassList = (value: string | null): string[] => {
.map((entry: string): string => entry.trim())
.filter((entry: string): boolean => entry.length > 0);
};
export const onReady = (fn: () => void): void => {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", fn, { once: true });
return;
}
fn();
};