Cookies & Consents Widget: JavaScript error in the customizer in some themes
When using the WordPress Customizer I am getting this error in the Chrome Inspector Tools:
Uncaught TypeError: Cannot read property 'classList' of null
at eu-cookie-law.min.js:2
at eu-cookie-law.min.js:2
It is the Jetpack eu-cookie-law because this is the full source: https://c0.wp.com/p/jetpack/8.5/_inc/build/widgets/eu-cookie-law/eu-cookie-law.min.js
The offending object is “n” which is set to “getElementById(‘eu-cookie-law’)”. I believe there should be a check for existence of the element:
if(n !== null && n.hasOwnProperty('classList'){ ... }
Could you let me know what theme you experienced this with?
Hello @jeherve it happens with any theme. I've checked on 5 different sites that I manage, each with a different theme, it happens on all of them. The error is not theme dependent. My hunch is that, since the Customizer works with an iframe, the targeted 'div' is not being found because it's inside the iframe?
Could you give me an example of a theme from one of those sites? I can't seem to reproduce with Twenty Twenty or Twenty Nineteen, but I wonder if this may have something to do with a specific set up of widget areas.
The error is occurring with these themes:
- Di Business
- Clean Retina
- Maidenhair It's not occurring with "Ignite" theme.
Thank you!
Hello, greetings. I am experiencing the same error. I'm working with Engitech theme.
Reported in 3149088-zen
Reported in 3174888-zen
same error reported at https://github.com/Automattic/jetpack/issues/18901 using Ahead theme