Alex-D / Cookies-EU-banner

1kb vanilla JS script which manages cookies consent banner display like asked by GDPR
http://alex-d.github.io/Cookies-EU-banner/
MIT License
441 stars 57 forks source link

Fix the launchFunction argument when not a function #56

Closed gladchinda closed 4 years ago

gladchinda commented 4 years ago

When constructing the CookiesEuBanner instance, it is possible that the argument passed as the launchFunction named parameter may not be a function.

// Boolean explicitly passed here
new CookiesEuBanner(false);

// Undefined implicitly passed here:
new CookiesEuBanner();

For any of the above scenarios, the code will throw a TypeError indicating that the designated launchFunction is not a function.

Hence, a type check is required to ascertain that the launchFunction is a function. And if not, a no-op function can be used as a fallback.

gladchinda commented 4 years ago

This pull request fixes this issue: #57

Alex-D commented 4 years ago

See my response: https://github.com/Alex-D/Cookies-EU-banner/issues/57#issuecomment-623745076