Harborn-digital / cookie-consent-bundle

Symfony bundle to append Cookie Consent to your website to comply to AVG/GDPR for cookies.
MIT License
18 stars 16 forks source link

[JS] event.target.matches not working on IE 11 #52

Closed grandmaster44 closed 4 years ago

grandmaster44 commented 4 years ago

Hi! Thanks for the bundle.

https://github.com/ConnectHolland/cookie-consent-bundle/blob/119ce69e8e7b9435a7c240fdecb2a3017be8ec79/Resources/public/js/cookie_consent.js#L25

https://caniuse.com/#feat=matchesselector As you can see event.target.matches not working on IE 11.

There are two solutions:

  1. add msMatchesSelector
    var matches = event.target.matches
                ? event.target.matches('.ch-cookie-consent__btn')
                : event.target.msMatchesSelector('.ch-cookie-consent__btn');
  2. addEventListener on cookieConsentForm
    var cookieConsentFormBtn = document.getElementsByClassName('ch-cookie-consent__btn')[0];
    // Submit form via ajax
    cookieConsentFormBtn.addEventListener('click', function () {...});
matthijsch commented 4 years ago

Thanks for your fix 👍