fix: 🐛 acceptCookie and denyCookie were trying to change domElements from cookie list event if not present
This commit is contained in:
parent
b78c05890e
commit
4a56bc765f
1 changed files with 14 additions and 8 deletions
|
|
@ -281,10 +281,13 @@ export default class CookieNotice {
|
|||
acceptCookie(cookieName: string) {
|
||||
const cookieOptions = this.getCookie(cookieName);
|
||||
this.setCookieStatus(cookieName, CookieStatus.true, cookieOptions);
|
||||
const cnSwitch = document.getElementById(`${cookieName}-switch`) as HTMLInputElement;
|
||||
const cnSwitchInput = cnSwitch!.querySelector("input") as HTMLInputElement;
|
||||
cnSwitchInput!.checked = true;
|
||||
cnSwitch!.ariaChecked = "true";
|
||||
const cnSwitch = document.getElementById(`${cookieName}-switch`) as HTMLInputElement | null;
|
||||
const cnSwitchInput = cnSwitch?.querySelector("input") as HTMLInputElement | null;
|
||||
if (!cnSwitch || !cnSwitchInput) {
|
||||
return;
|
||||
}
|
||||
cnSwitchInput.checked = true;
|
||||
cnSwitch.ariaChecked = "true";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -301,10 +304,13 @@ export default class CookieNotice {
|
|||
denyCookie(cookieName: string) {
|
||||
const cookieOptions = this.getCookie(cookieName);
|
||||
this.setCookieStatus(cookieName, CookieStatus.false, cookieOptions);
|
||||
const cnSwitch = document.getElementById(`${cookieName}-switch`) as HTMLInputElement;
|
||||
const cnSwitchInput = cnSwitch!.querySelector("input") as HTMLInputElement;
|
||||
cnSwitchInput!.checked = false;
|
||||
cnSwitch!.ariaChecked = "false";
|
||||
const cnSwitch = document.getElementById(`${cookieName}-switch`) as HTMLInputElement | null;
|
||||
const cnSwitchInput = cnSwitch?.querySelector("input") as HTMLInputElement | null;
|
||||
if (!cnSwitch || !cnSwitchInput) {
|
||||
return;
|
||||
}
|
||||
cnSwitchInput.checked = false;
|
||||
cnSwitch.ariaChecked = "false";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue