I tried to apply you solution to my example where more than one button could appear within the DOM. Don’t know if it is worth the effort though, it just feels cumbersome.
Solution 1: Remembering the previously clicked button
Solution 2: Removing active states recklessly
I think this topic is not really interesting in terms of performance, but I was just wondering how others would approach this problem.