Skip to content

Commit d6bc92d

Browse files
authored
Merge pull request #297 from drupalprojects/7.x-3.x--aria-roles
Removing menu and menuitem roles
2 parents 2488707 + 00e650b commit d6bc92d

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

includes/menu.inc

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
* Implements theme_menu_tree().
99
*/
1010
function kalatheme_menu_tree($variables) {
11-
// Set the aria role to menu
12-
return '<ul class="menu clearfix" role="menu">' . $variables['tree'] . '</ul>';
11+
return '<ul class="menu clearfix">' . $variables['tree'] . '</ul>';
1312
}
1413

1514

@@ -21,10 +20,6 @@ function kalatheme_menu_link($variables) {
2120
$element = $variables['element'];
2221
$sub_menu = '';
2322
$element['#attributes']['role'] = 'presentation';
24-
// Enforce aria-role="menuitem"
25-
$role = array('role'=> 'menuitem' );
26-
$element['#localized_options']['attributes'] = isset($element['#localized_options']['attributes']) ? $element['#localized_options']['attributes']
27-
+= $role : $role;
2823
if ($element['#below']) {
2924
$sub_menu = drupal_render($element['#below']);
3025
}
@@ -37,11 +32,6 @@ function kalatheme_menu_link($variables) {
3732
function kalatheme_links__system_main_menu($variables) {
3833
$links = $variables['links'];
3934
$attributes = $variables['attributes'];
40-
41-
// Navbar best described by menubar, only add attribute if role="menu" isn't set
42-
if(!isset($attributes['role'])){
43-
$attributes['role'] = 'menubar';
44-
}
4535
$heading = $variables['heading'];
4636
unset($links['#sorted']);
4737
unset($links['#theme_wrappers']);
@@ -92,8 +82,6 @@ function kalatheme_links__system_main_menu($variables) {
9282
if ( isset($link['#localized_options']['attributes'])){
9383
$link['#options']['attributes'] += $link['#localized_options']['attributes'];
9484
}
95-
// lastly add in the role=menuitem for links
96-
$link['#options']['attributes']['role'] = 'menuitem';
9785
// Add first/last/active classes to help out themers.
9886
if ($i == 1) {
9987
$class[] = 'first';
@@ -179,7 +167,6 @@ function kalatheme_links__system_main_menu($variables) {
179167
'links' => $link['#below'],
180168
'attributes' => array(
181169
'class' => array('dropdown-menu'),
182-
'role' => 'menu',
183170
'aria-labelledby' => $dropdown_id,
184171
'aria-expanded' => 'false'
185172
),
@@ -295,7 +282,7 @@ function kalatheme_menu_local_tasks(&$variables) {
295282

296283
if (!empty($variables['primary'])) {
297284
$variables['primary']['#prefix'] = '<h3 class="sr-only">' . t('Primary tabs') . '</h3>';
298-
$variables['primary']['#prefix'] = '<ul class="nav nav-pills" role="menu">';
285+
$variables['primary']['#prefix'] = '<ul class="nav nav-pills">';
299286
$variables['primary']['#suffix'] = '</ul>';
300287
if (!empty($variables['secondary'])) {
301288
$variables = _kalatheme_associate_parent_tasks($variables);
@@ -342,16 +329,14 @@ function kalatheme_menu_local_task($variables) {
342329
$link_text .= ' <span class="caret" aria-hidden="true"></span>';
343330
$output = '<li class="' . implode(' ', $classes) . '" role="presentation">';
344331
$output .= l($link_text, $link['href'], $link['localized_options']);
345-
$output .= '<ul class="dropdown-menu" role="menu">';
332+
$output .= '<ul class="dropdown-menu">';
346333
$output .= drupal_render($children);
347334
$output .= '</ul>';
348335
$output .= '</li>';
349336
return $output;
350337
}
351338
else {
352339
$options = $link['localized_options'];
353-
$role= array('role'=> 'menuitem');
354-
$options['attributes'] = isset( $options['attributes'] ) ? $options['attributes'] += $role : $role;
355340
return '<li class="' . implode(' ', $classes) . '" role="presentation">' . l($link_text, $link['href'], $link['localized_options']) . "</li>\n";
356341
}
357342
}
@@ -367,7 +352,7 @@ function kalatheme_menu_local_actions($variables) {
367352
// Render the dropdown.
368353
$output = $container_attributes ? '<li' . $container_attributes . '>' : '<li>';
369354
$output .= $toggle_attributes ? '<a role="button"' . $toggle_attributes . '><span class="glyphicon glyphicon-wrench fa fa-wrench" aria-hidden="true"></span> ' . t('Actions') . '<span class="caret" aria-hidden="true"></span></a>' : '<a role="button">' . t('Actions') . '<span class="caret" aria-hidden="true"></span></a>';
370-
$output .= $content_attributes ? '<ul' . $content_attributes . ' role="menu">' : '<ul role="menu">';
355+
$output .= $content_attributes ? '<ul' . $content_attributes . '>' : '<ul role="menu">';
371356
$output .= drupal_render($variables['menu_actions']);
372357
$output .= '</ul>';
373358
$output .= '</li>';
@@ -384,10 +369,7 @@ function kalatheme_menu_local_action($variables) {
384369
$output = "<li role=\"presenation\">";
385370
if (isset($link['href'])) {
386371
$options = isset($link['localized_options']) ? $link['localized_options'] : array();
387-
// Adding ARIA Attributes for the link as a menuitem
388-
// @link http://www.w3.org/TR/wai-aria/roles#menuitem
389372
$a11y_attr = array(
390-
'role'=>'menuitem',
391373
'tab-index' => '-1'
392374
);
393375
$options['attributes'] = isset($options['attributes']) ? $options['attributes'] += $a11y_attr : $a11y_attr;

0 commit comments

Comments
 (0)