1(function ($, Drupal) { 2 Drupal.behaviors.uswds_ckeditor_integration_accordion = { 3 attach(context, settings) { 4 // Seems to be a bug in ckeditor5 using buttons and maintaining text 5 // See https://github.com/ckeditor/ckeditor5/issues/13268 6 $('.text-formatted div.usa-accordion__button').each(function () { 7 const outer = this.outerHTML; 8 9 // Replace opening tag 10 let regex = new RegExp(`<${this.tagName}`, 'i'); 11 let newTag = outer.replace(regex, '<button'); 12 13 // Replace closing tag 14 regex = new RegExp(`</${this.tagName}`, 'i'); 15 newTag = newTag.replace(regex, '</button'); 16 17 $(this).replaceWith(newTag); 18 }); 19 20 let $containerCounter = 0; 21 $('main .text-formatted .usa-accordion').each(function () { 22 let $itemCounter = 0; 23 $('.usa-accordion__button', this).each(function () { 24 if (!$(this).attr('aria-controls')) { 25 $(this).attr('aria-controls', `${$containerCounter}-${$itemCounter}`); 26 $itemCounter++; 27 } 28 }); 29 30 $itemCounter = 0; 31 $('.usa-accordion__content', this).each(function () { 32 if (!$(this).attr('id')) { 33 $(this).attr('id', `${$containerCounter}-${$itemCounter}`); 34 $itemCounter++; 35 } 36 }); 37 38 $containerCounter++; 39 }); 40 }, 41 }; 42})(jQuery, Drupal);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.