From 713e67743b149fa8b094f1de2d27c7881d7170f4 Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Wed, 2 Jan 2013 17:58:48 -0800 Subject: [PATCH] Issue #1848684 by Liam Morland, mgifford: Add ARIA role to DETAILS. --- core/includes/form.inc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/includes/form.inc b/core/includes/form.inc index b23d708c8fdf..0ef70f8661ab 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -2869,7 +2869,15 @@ function theme_details($variables) { $output = '<details' . new Attribute($element['#attributes']) . '>'; if (!empty($element['#title'])) { - $output .= '<summary>' . $element['#title'] . '</summary>'; + $summary_attributes = new Attribute(array( + 'role' => 'button', + )); + if (!empty($element['#attributes']['id'])) { + $summary_attributes['aria-controls'] = $element['#attributes']['id']; + } + $summary_attributes['aria-expanded'] = empty($element['#attributes']['open']) ? FALSE : TRUE; + $summary_attributes['aria-pressed'] = $summary_attributes['aria-expanded']; + $output .= '<summary' . $summary_attributes . '>' . $element['#title'] . '</summary>'; } $output .= '<div class="details-wrapper">'; if (!empty($element['#description'])) { -- GitLab