fix: 🐛 Cookie Modal list 'toggleCookie' was using wrong HTMLElement

This commit is contained in:
Jérémy Munsch 2024-05-29 11:15:48 +02:00
parent 4f2a845dd4
commit 998da390ac
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -748,29 +748,21 @@ export default class CookieNotice {
cnSwitch.setAttribute("aria-labelledby", `${cookieName}-desc`);
cnSwitch.setAttribute("aria-describedby", `${cookieName}-desc`);
const toggleCookie = () => {
const toggleCookie = (activate:boolean) => {
this.setCookieStatus(
cookieName,
cnSwitch.checked ? CookieStatus.true : CookieStatus.false,
activate ? CookieStatus.true : CookieStatus.false,
cookieConfig
);
};
this.addEvent(cnSwitch, "click", () => {
toggleCookie();
if (cnSwitchInput.checked) {
cnSwitch.ariaChecked = "true";
} else {
cnSwitch.ariaChecked = "false";
}
toggleCookie(cnSwitchInput.checked);
cnSwitch.ariaChecked = cnSwitchInput.checked ? "true" : "false";
});
this.addEventKbdValidate(cnSwitch, () => {
toggleCookie();
toggleCookie(cnSwitchInput.checked);
cnSwitchInput.checked = !cnSwitchInput.checked;
if (cnSwitchInput.checked) {
cnSwitch.ariaChecked = "true";
} else {
cnSwitch.ariaChecked = "false";
}
cnSwitch.ariaChecked = cnSwitchInput.checked ? "true" : "false";
});
this.cookiesUnorderedList.append(cookie);