I am trying to loop over a DOM element and add aria-labels to them.
const dayAriaLabels = {
Mo: 'Monday',
Tu: 'Tuesday',
We: 'Wednesday',
Th: 'Thursday',
Fr: 'Friday',
Sa: 'Saturday',
Su: 'Sunday',
};
setTimeout(() => {
const selectDomElement = document.querySelectorAll('.MuiPickersCalendarHeader-dayLabel');
if (!isEmpty(selectDomElement)) {
selectDomElement.forEach((label) => {
Object.entries(dayAriaLabels).forEach(([key, value]) => {
label.setAttribute('aria-label', value);
});
});
}
}, 100);
However when I inspect the dom element this happens
As you can see only Sunday is added? What is happening here? why cant I add all of the days from the object?