Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs Site] remove unnecessary DOMContentLoaded listeners #16834

Merged
merged 4 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/components/overrides/Head.astro
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,10 @@ if (Astro.props.entry.data.external_link) {
<script>
import littlefoot from "littlefoot";

document.addEventListener("DOMContentLoaded", () => {
littlefoot();
document
.querySelectorAll("span.littlefoot")
.forEach((x) => x.classList.add("not-content"));
});
littlefoot();
document
.querySelectorAll("span.littlefoot")
.forEach((x) => x.classList.add("not-content"));
</script>
<script>
import mermaid from "mermaid";
Expand Down
18 changes: 8 additions & 10 deletions src/pages/changelog/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,15 @@ const { products, productAreas, changelogs } = await getChangelogs();
<script>
import StickyHeader from "@codingheads/sticky-header";

document.addEventListener("DOMContentLoaded", () => {
const navHeightRem = getComputedStyle(document.body).getPropertyValue(
"--sl-nav-height",
);
const navHeightPx = Number(navHeightRem.split("rem")[0]) * 16 + 16;
const navHeightRem = getComputedStyle(document.body).getPropertyValue(
"--sl-nav-height",
);
const navHeightPx = Number(navHeightRem.split("rem")[0]) * 16 + 16;

const headers = document.querySelectorAll<HTMLElement>("[data-date] > h2");
headers.forEach(
(header) => new StickyHeader(header, { offset: 0 - navHeightPx }),
);
});
const headers = document.querySelectorAll<HTMLElement>("[data-date] > h2");
headers.forEach(
(header) => new StickyHeader(header, { offset: 0 - navHeightPx }),
);

const productFilter = document.querySelector<HTMLSelectElement>("#products");
productFilter?.addEventListener("change", filterEntries);
Expand Down
7 changes: 3 additions & 4 deletions src/pages/products.astro
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const groups = productGroups(products);
input.addEventListener("change", filterProducts);
});

document.addEventListener("DOMContentLoaded", () => {
function initProducts() {
const params = new URLSearchParams(window.location.search);

const groups = params.get("product-group");
Expand All @@ -170,13 +170,12 @@ const groups = productGroups(products);
if (!filters) return;

for (const filter of filters) {
console.log(groups);
console.log(filter.id);
if (groups.includes(filter.id)) {
filter.checked = true;
}
}

filterProducts();
});
}
initProducts();
</script>
Loading