comparison core/misc/details-aria.es6.js @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 /**
2 * @file
3 * Add aria attribute handling for details and summary elements.
4 */
5
6 (function ($, Drupal) {
7 /**
8 * Handles `aria-expanded` and `aria-pressed` attributes on details elements.
9 *
10 * @type {Drupal~behavior}
11 */
12 Drupal.behaviors.detailsAria = {
13 attach() {
14 $('body').once('detailsAria').on('click.detailsAria', 'summary', (event) => {
15 const $summary = $(event.currentTarget);
16 const open = $(event.currentTarget.parentNode).attr('open') === 'open' ? 'false' : 'true';
17
18 $summary.attr({
19 'aria-expanded': open,
20 'aria-pressed': open,
21 });
22 });
23 },
24 };
25 }(jQuery, Drupal));