Make WordPress Core

Changeset 59911


Ignore:
Timestamp:
03/03/2025 08:06:03 PM (21 months ago)
Author:
joedolson
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentytwelve/js/navigation.js

    r30746 r59911  
    2121        }
    2222
     23        // Assign an ID for the default page list if no menu is set as Primary.
     24        if ( ! menu.id ) {
     25                menu.id = 'twentytwelve-page-list-menu';
     26        }
     27
     28        button.setAttribute( 'aria-controls', menu.id );
     29        button.setAttribute( 'aria-expanded', 'false' );
     30
    2331        button.onclick = function() {
    2432                if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
    … …  
    2735
    2836                if ( -1 !== button.className.indexOf( 'toggled-on' ) ) {
     37                        button.setAttribute( 'aria-expanded', 'false' );
    2938                        button.className = button.className.replace( ' toggled-on', '' );
    3039                        menu.className = menu.className.replace( ' toggled-on', '' );
    3140                } else {
     41                        button.setAttribute( 'aria-expanded', 'true' );
    3242                        button.className += ' toggled-on';
    3343                        menu.className += ' toggled-on';
Note: See TracChangeset for help on using the changeset viewer.