Skip to content

Commit 5440bf1

Browse files
authored
resolves #47 add aria- attributes to mobile menu button; replace data-target with aria-controls (PR #133)
1 parent 753f4d7 commit 5440bf1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/js/05-mobile-navbar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
function toggleNavbarMenu (e) {
99
e.stopPropagation() // trap event
1010
var html = document.documentElement
11-
var menu = document.getElementById(this.dataset.target)
11+
var menu = document.getElementById(this.getAttribute('aria-controls') || this.dataset.target)
1212
if (!menu.classList.contains('is-active') && /mobi/i.test(window.navigator.userAgent)) {
1313
if (Math.round(parseFloat(window.getComputedStyle(html).minHeight)) !== window.innerHeight) {
1414
html.style.setProperty('--vh', window.innerHeight / 100 + 'px')
@@ -17,7 +17,7 @@
1717
}
1818
}
1919
html.classList.toggle('is-clipped--navbar')
20-
this.classList.toggle('is-active')
20+
navbarBurger.setAttribute('aria-expanded', this.classList.toggle('is-active'))
2121
menu.classList.toggle('is-active')
2222
}
2323
})()

src/partials/header-content.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="navbar-brand">
44
<a class="navbar-item logo" title="Asciidoctor" href="https://asciidoctor.org"><img src="{{{uiRootPath}}}/img/asciidoctor-logo.svg" alt="Asciidoctor" width="48"></a>
55
<a class="navbar-item title" href="{{#with (and site.url site.homeUrl)}}{{{@root.site.url}}}{{{this}}}{{else}}{{{siteRootPath}}}{{/with}}">{{site.title}}</a>
6-
<button class="navbar-burger" data-target="topbar-nav">
6+
<button class="navbar-burger" aria-controls="topbar-nav" aria-expanded="false" aria-label="Toggle main menu">
77
<span></span>
88
<span></span>
99
<span></span>

0 commit comments

Comments
 (0)