diff options
author | Zarino Zappia <mail@zarino.co.uk> | 2018-09-14 17:32:23 +0100 |
---|---|---|
committer | Zarino Zappia <mail@zarino.co.uk> | 2018-09-19 11:14:56 +0100 |
commit | 8f2ce13bec69151aa10ef0676d9c417b0fde6fa3 (patch) | |
tree | 144c18a40f58c5a81d379b9267b12845d41ee16b | |
parent | 240c248ec14cd339f59a9977cd2539bc0ce1f39e (diff) |
Avoid exception if homepage does not include a .report-a-problem-btn
Some cobrands (like Collideoscope) don’t have a .report-a-problem-btn
in their mobile nav menu, so .querySelector() would raise an exception
when we tried to attach an event listener to it.
Now we check that the element exists before attaching the listener.
-rw-r--r-- | web/js/front.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/web/js/front.js b/web/js/front.js index 67486888b..db0228597 100644 --- a/web/js/front.js +++ b/web/js/front.js @@ -17,7 +17,7 @@ document.getElementById('pc').focus(); } var lk = document.querySelector('span.report-a-problem-btn'); - if (lk.addEventListener) { + if (lk && lk.addEventListener) { lk.addEventListener('click', function(){ scrollTo(0,0); }); |