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
439 stars 57 forks source link

Provide some null safety for #removeBanner #40

Closed xijo closed 5 years ago

xijo commented 5 years ago

In our production environment occasionally the following error occurred: e.parentNode is null at the following position:

cookies-eu-banner.js:178:0:in `banner'

176     removeBanner: function (banner, wait) {
177       setTimeout (function() {
178         banner.parentNode.removeChild(banner);
179       }, wait);
180     }

We figured it might be the work of some add blocker or something similar, but were not able to hunt it down.

So let's get rid of the error - the banner won't need any removal if its not there in the first place, right?

Thanks and best, Jo

Alex-D commented 5 years ago

Thanks for the fix :)