refactor: replace DOMContentLoaded with onReady utility
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { onReady } from "./utils";
|
||||
|
||||
const initSortFilter = (): void => {
|
||||
const sortSelect = document.getElementById("sort-select") as HTMLSelectElement | null;
|
||||
const orderSelect = document.getElementById("order-select") as HTMLSelectElement | null;
|
||||
@@ -21,4 +23,4 @@ const initSortFilter = (): void => {
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", initSortFilter);
|
||||
onReady(initSortFilter);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { onReady } from "./utils";
|
||||
|
||||
type Theme = "light" | "dark";
|
||||
|
||||
const colorSchemeQuery = window.matchMedia?.("(prefers-color-scheme: dark)") ?? null;
|
||||
@@ -17,8 +19,4 @@ const initTheme = (): void => {
|
||||
colorSchemeQuery?.addEventListener("change", () => applyTheme(getPreferredTheme()));
|
||||
};
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", initTheme);
|
||||
} else {
|
||||
initTheme();
|
||||
}
|
||||
onReady(initTheme);
|
||||
|
||||
Reference in New Issue
Block a user