MyopicVicar
MyopicVicar copied to clipboard
Verify elements are non-null before adding event listener
When loading www.freecen.org.uk, I see a few console errors.
Two of these are Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
.
This change checks the elements having click listeners attached are truthy before reading their addEventListener
(or attachEvent
) attributes. It also future-proofs the subsequent check for element #trigger-offcanvas-old
.