Minor nitpick: if you're using classList, you might as well also use it to toggle the "open" class (instead of y.setAttribute('class', ...)):
y.classList.toggle('open', y == e.target && !y.classList.contains('open'))
As the behavior of what to do with the "open" class is only dependent on whether `y` is the clicked element, i find this version more readable:
y == e.target ? y.classList.toggle('open') : y.classList.remove('open'))
Aaaand, it can be made less readable again by selecting the classList method to call conditionally :)
y.classList[y == e.target ? 'toggle' : 'remove']('open')