From 8da5918fbc0d1c9d2d665ade1b51ebe22a1a0f79 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Tue, 15 Dec 2015 13:24:13 +0000 Subject: [PATCH] Accessibility: Add an ARIA role `button` to links that behave like buttons when JavaScript is on. Introduces a simple way to give a proper semantics of `button` to links that behave like UI controls when JavaScript is on and behave like actual links when JavaScript is off. First implementation on the Terms list table. Patch prepared during WordCamp US 2015 Contributor Day. Props mcapybara, garusky, takayukister. See #26504. Fixes #34867. git-svn-id: https://develop.svn.wordpress.org/trunk@35947 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-terms-list-table.php | 4 ++-- src/wp-admin/js/common.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index 765b1a36b3..4bce2e60b2 100644 --- a/src/wp-admin/includes/class-wp-terms-list-table.php +++ b/src/wp-admin/includes/class-wp-terms-list-table.php @@ -430,10 +430,10 @@ class WP_Terms_List_Table extends WP_List_Table { $actions = array(); if ( current_user_can( $tax->cap->edit_terms ) ) { $actions['edit'] = '' . __( 'Edit' ) . ''; - $actions['inline hide-if-no-js'] = '' . __( 'Quick Edit' ) . ''; + $actions['inline hide-if-no-js'] = '' . __( 'Quick Edit' ) . ''; } if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) - $actions['delete'] = "term_id ) . "'>" . __( 'Delete' ) . ""; + $actions['delete'] = "term_id ) . "'>" . __( 'Delete' ) . ""; if ( $tax->public ) $actions['view'] = '' . __( 'View' ) . ''; diff --git a/src/wp-admin/js/common.js b/src/wp-admin/js/common.js index 796e1400f4..ae49ee0e41 100644 --- a/src/wp-admin/js/common.js +++ b/src/wp-admin/js/common.js @@ -897,10 +897,20 @@ $document.ready( function() { } }; + // Add an ARIA role `button` to elements that behave like UI controls when JavaScript is on. + function aria_button_if_js() { + $( '.aria-button-if-js' ).attr( 'role', 'button' ); + } + + $( document ).ajaxComplete( function() { + aria_button_if_js(); + }); + window.wpResponsive.init(); setPinMenu(); currentMenuItemHasPopup(); makeNoticesDismissible(); + aria_button_if_js(); $document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', setPinMenu ); });