From 22f5c7610b9b11253ad419ced04e3ab61a271bbf Mon Sep 17 00:00:00 2001 From: Florian CHOMETON Date: Fri, 15 Apr 2022 13:52:11 +0200 Subject: [PATCH] Add aria-expanded attribute on catToggleBtn --- tarteaucitron.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 0f1bb75..85b2f66 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -380,7 +380,7 @@ var tarteaucitron = { for (i = 0; i < cat.length; i += 1) { html += '
  • '; html += '
    '; - html += ' '; + html += ' '; html += '
    '; html += '
    '; html += ' ' + tarteaucitron.lang[cat[i]].details; @@ -749,6 +749,11 @@ var tarteaucitron = { toggleBtns[i].dataset.index = i; tarteaucitron.addClickEventToElement(toggleBtns[i], function () { tarteaucitron.userInterface.toggle('tarteaucitronDetails' + cat[this.dataset.index], 'tarteaucitronInfoBox'); + if (document.getElementById('tarteaucitronDetails' + cat[this.dataset.index]).style.display === 'block') { + this.setAttribute('aria-expanded', 'true'); + } else { + this.setAttribute('aria-expanded', 'false'); + } return false; }); }