Skip to content

Commit

Permalink
[BUGFIX] Add consent replacement parent element due to unavailability…
Browse files Browse the repository at this point in the history
… after removing the original event target
  • Loading branch information
featdd committed Jun 12, 2023
1 parent 2672b1f commit 9ff39d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
10 changes: 9 additions & 1 deletion Resources/Private/Assets/JavaScript/CookieConsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@

consentEventDispatch: function(originalReplaceButtonClickEvent) {
const that = this;
let parentElement = undefined;

if (typeof originalReplaceButtonClickEvent !== 'undefined') {
parentElement = originalReplaceButtonClickEvent.target.closest('.cookie-consent-replacement').parentNode;
}

if (false === this.hasCookie()) {
throw new Error('Can\'t do event dispatch if the necessary cookie hasn\'t been set');
Expand Down Expand Up @@ -665,7 +670,10 @@
'cookieConsentButtonsReplaced',
{
detail: Object.assign(
{ originalEvent: originalReplaceButtonClickEvent },
{
originalEvent: originalReplaceButtonClickEvent,
parentElement: parentElement
},
this.getCookie(),
),
},
Expand Down
Loading

0 comments on commit 9ff39d7

Please sign in to comment.