[3.1.0] Fix bug with addAttribute when called multiple times on the same element