Files
Keavon Chambers 45f0d21f25 Lint the website with the frontend's ESLint config instead of a separate copy, selecting elements by data attributes (#4655)
* Lint the website with the frontend's ESLint config instead of a diverging copy, selecting elements by data attributes

* Give the crate graph's marker attribute a value, cache npm in the website workflow, and mention installing the website's packages
2026-10-07 16:05:42 -07:00

19 lines
710 B
JavaScript

document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll("[data-tree-node]").forEach((toggle) => {
toggle.addEventListener("click", (event) => {
// Prevent link click from also toggling parent
if (event.target instanceof HTMLElement && event.target.tagName.toLowerCase() === "a") return;
const nestedList = toggle.parentElement?.querySelector("[data-nested]");
if (nestedList) {
toggle.classList.toggle("expanded");
nestedList.classList.toggle("active");
}
});
});
// Expand the first level by default
const firstLevel = document.querySelector("[data-structure-outline] [data-tree-node]");
if (firstLevel instanceof HTMLElement) firstLevel.click();
});