Skip to content

Commit

Permalink
Write out el as element
Browse files Browse the repository at this point in the history
  • Loading branch information
markteekman committed Mar 19, 2023
1 parent 3a1bb62 commit 5db5e25
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/Navigation.astro
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ import { DarkMode } from 'accessible-astro-components'
// execution
mainMenu &&
mainMenu.addEventListener('keydown', (event) => {
const el = event.target as Element
const currentMenuItem = el.closest('li')
const element = event.target as Element
const currentMenuItem = element.closest('li')
const menuItems = [...mainMenu.querySelectorAll('.menu-item')]
const currentDropdownMenu = el.closest('.has-dropdown button')
const currentDropdownMenuItem = el.closest('.has-dropdown li')
const currentDropdownMenu = element.closest('.has-dropdown button')
const currentDropdownMenuItem = element.closest('.has-dropdown li')
const currentIndex = menuItems.findIndex((item) => item === currentMenuItem)

const key = event.key
Expand Down Expand Up @@ -176,7 +176,7 @@ import { DarkMode } from 'accessible-astro-components'
}

if (key === 'Escape') {
const currentDropdownMenu = (currentDropdownList as Element).previousElementSibling
const currentDropdownMenu = (currentDropdownList as Element).previousElementSibling
targetItem = currentDropdownMenu.parentNode
closeAllDropdownMenus()
}
Expand All @@ -197,8 +197,8 @@ import { DarkMode } from 'accessible-astro-components'

window.addEventListener('resize', checkMenuSize)
window.addEventListener('click', (event) => {
const el = event.target as Element
if (!el.hasAttribute('aria-haspopup') && !el.classList.contains('submenu-item')) {
const element = event.target as Element
if (!element.hasAttribute('aria-haspopup') && !element.classList.contains('submenu-item')) {
closeAllDropdownMenus()
}
})
Expand Down

0 comments on commit 5db5e25

Please sign in to comment.