Skip to content

Commit

Permalink
fix: querySelectorAll array in safari (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
niccofyren authored Nov 26, 2024
1 parent b1e7ff6 commit 67452af
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/components/navigation/NavItem.astro
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,19 @@ const subItemsWithParent: Array<
const isTouchDevice =
"ontouchstart" in window || navigator.maxTouchPoints > 0;

const navItems: SubNavComponents[] = document
.querySelectorAll("[data-component='nav-item']")
.values()
const navItems: SubNavComponents[] = [
...document.querySelectorAll("[data-component='nav-item']"),
]
.map((navItem) => {
const trigger = navItem.querySelector("[data-part='trigger']");
const subMenu = navItem.querySelector("[data-part='sub-menu']");
const mainLink = navItem.querySelector("[data-part='main-link']");
return { mainLink, trigger, subMenu, navItem };
return { mainLink, trigger, subMenu, navItem } as SubNavComponents;
})
.filter(
({ mainLink, navItem, trigger, subMenu }) =>
mainLink && navItem && trigger && subMenu,
)
.toArray() as unknown as SubNavComponents[];
);

function expand(index: number, expanded: boolean) {
const { navItem, trigger, subMenu } = navItems[index] || {};
Expand Down

0 comments on commit 67452af

Please sign in to comment.