JS uncaught TypeError
-
Hello,
I’m not sure that this is the best way to communicate about observed errors, but I would like to raise an issue with the botiga/assets/js/custom.min.js file.
Uncaught TypeError: Cannot read properties of null (reading ‘classList’)
at Object.events (custom.min.js?ver=1.0.8:1)
at Object.init (custom.min.js?ver=1.0.8:1)
at HTMLDocument.<anonymous> (custom.min.js?ver=1.0.8:1)The error is raised from the line 675 of the non minified custom.js file
plus.classList.add(‘show’);
When there is only 1 or less item in stock (woocommerce), the “.botiga-quantity-plus” element is not added to html. The div container “.quantity” also has the “.hidden” class and a single child of <input>, hidden with quantity 1.
Therefore, the search (line 673)
var plus = qty[i].querySelector(‘.botiga-quantity-plus’)
returns null and the .classList.add function raises the previously mentionned error.I suggest that the code should be edited to either apply the code from line 675 to 692 if the plus and minus element are not null, or to alter the preceding search for elements to only include non ‘.hidden’ quantity container
var qty = document.querySelectorAll(‘form.cart .quantity, .botiga-quick-view-popup .quantity, .woocommerce-cart-form__cart-item.cart_item .quantity, .botiga-single-sticky-add-to-cart-wrapper-content .quantity’);
(the last propose solution may have unknown side effect)
Best regards
The topic ‘JS uncaught TypeError’ is closed to new replies.
