Security update to Drupal 8.4.6
[yaffs-website] / web / core / misc / details-aria.es6.js
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));