Bug: Javascript Error Null Checkbox
-
Wonder if other users have noticed an error in the console log on their site. Debugging another issue we found that CF7 was generating the following error from within the index.js script.
Uncaught TypeError: a is nullInvestigation shows that the error is generated from within the following block of code:
e.querySelectorAll(‘.wpcf7-acceptance’).forEach((e) => {
if (!t || e.classList.contains(‘optional’)) return;
const a = e.querySelector(‘input[type=”checkbox”]’);
((e.classList.contains(‘invert’) && a.checked) ||
(!e.classList.contains(‘invert’) && !a.checked)) &&
(t = !1);
}),
It would appear the code is looking for the input checkbox HTML element as a direct descendant of the .wpcf7-acceptance span element to see if it is checked. However the HTML for the page shows that the input checkbox is not a direct descendent of this element and is instead wrapped within a <span class=”wpcf7-list-item“> element. This appears to result in ‘a’ returning null in the code above.
- You must be logged in to reply to this topic.