Filipe, this is not what you're trying to achieve, but the consequence/side effect of that.
In order for anyone to help you (e.g. me, community, OS R&D?), please explain what are you trying to achieve (as a whole) - the scenario that lead to this "finding".
BTW, regarding how browsers work: the classes don't get classes duplicated - the browser computes them into the CSSOM