From ffc28bdb3741601f9153128abb3a2049a2fcc856 Mon Sep 17 00:00:00 2001 From: Nicolai Rosdahl Tellefsen Date: Tue, 26 Nov 2024 18:36:38 +0100 Subject: [PATCH] fix: querySelectorAll array in safari --- src/components/navigation/NavItem.astro | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/navigation/NavItem.astro b/src/components/navigation/NavItem.astro index 3acacef..0168c21 100644 --- a/src/components/navigation/NavItem.astro +++ b/src/components/navigation/NavItem.astro @@ -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] || {};