blob: c629719a3fc64404d7caedf9ace776fa024aed22 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/**
* @file
* Add aria attribute handling for details and summary elements.
*/
(function ($, Drupal) {
/**
* Handles `aria-expanded` and `aria-pressed` attributes on details elements.
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.detailsAria = {
attach() {
$(once('detailsAria', 'body')).on(
'click.detailsAria',
'summary',
(event) => {
const $summary = $(event.currentTarget);
const open =
$(event.currentTarget.parentNode).attr('open') === 'open'
? 'false'
: 'true';
$summary.attr({
'aria-expanded': open,
});
},
);
},
};
})(jQuery, Drupal);
|