Bundled Themes: Twenty Twelve: Add ARIA attributes on menu toggle.

Add `aria-expanded` and `aria-controls` attributes to the Twenty Twelve mobile menu toggle.

Props bschneidewind, joedolson, sabernhardt, umeshsinghin.
Fixes #62892.

git-svn-id: https://develop.svn.wordpress.org/trunk@59911 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Dolson 2025-03-03 20:06:03 +00:00
parent f578d8ebab
commit 5aa3534c2d

View File

@ -20,15 +20,25 @@
return;
}
// Assign an ID for the default page list if no menu is set as Primary.
if ( ! menu.id ) {
menu.id = 'twentytwelve-page-list-menu';
}
button.setAttribute( 'aria-controls', menu.id );
button.setAttribute( 'aria-expanded', 'false' );
button.onclick = function() {
if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
menu.className = 'nav-menu';
}
if ( -1 !== button.className.indexOf( 'toggled-on' ) ) {
button.setAttribute( 'aria-expanded', 'false' );
button.className = button.className.replace( ' toggled-on', '' );
menu.className = menu.className.replace( ' toggled-on', '' );
} else {
button.setAttribute( 'aria-expanded', 'true' );
button.className += ' toggled-on';
menu.className += ' toggled-on';
}