Add this to the component, so these buttons will work on initial load.
const clearElements = document.querySelectorAll('[data-filter-clear-elements]');
clearElements.forEach((element) => {
if (element instanceof HTMLElement) {
element.addEventListener('click', (e) => {
e.preventDefault();
const data = JSON.parse(element.getAttribute('data-filter-clear-elements'));
this.clearElements(data);
});
}
});