adding a return to prevent erros when elements not on the page

This commit is contained in:
Antoine M 2023-11-27 16:27:17 +01:00
parent 335f7ea088
commit 40728d2945

View File

@ -148,12 +148,15 @@ export default function filterPublicationsInit() {
const filterButtons = document.querySelectorAll('.filters-toolbar__action-button');
const loadAllbutton = document.querySelector('.filters-toolbar__action-button--load-all');
if (!filterButtons) return;
filterButtons.forEach((button) => {
const publicationType = button.getAttribute('data-publication-type');
button.addEventListener('click', (e) => {
filterPublications(publicationType, e);
});
});
if (!loadAllbutton) return;
loadAllbutton.addEventListener('click', (e) => {
const publicationType = loadAllbutton.getAttribute('data-publication-type');
filterPublications(publicationType, e);