Menubar
Initializing a <button>
menubar with <ul hidden role='menu'>
Required Blueprint
Javascript checks
document.querySelector(id) // (1)
// Button with text (2)
document.querySelector(`#${id} button`)
// Clickable menu items (3)
document.querySelector(`#${id} ul[hidden][role=menu]`)
document.querySelectorAll(`#${id} ul[hidden][role=menu] > li`)
document.querySelectorAll(`#${id} ul[hidden][role=menu] > li a`)
- The container will contain component DOM nodes
- Child
<button>
- Child
<ul hidden role='menu'>
with direct children<li>
containing an<a>
element.
Sample + Implementation
- Common script to both menubar and listbox
- Specific script enabling
doMenu()
Selector Styling
When an <li>
on the menubar receives :focus
:
data-ok='true'
appears on<li>
.data-ok='false'
is set on the other<li>
aria-activedescendant
appears on<ul>
pointing to the auto-generated id of<li>
.
These can then be used as a selector to style the focused element.