I played around with the example page https://en.wikipedia.beta.wmflabs.org/wiki/Dog (and others) and noticed a misbehavior that worries me quite much. First, I wondered about some broken HTML in the references section:
<a class="mw-cite-up-arrow-backlink" aria-label="Jump back up" title="Jump back up" href="#cite_ref-5">^</a>
<b><a href="#cite_ref-5" aria-label="Jump up" title="Jump up" class=""></a></b>
Notice that the line with the `<b>` is a broken link with no text.
Steps to reproduce:
* Go to https://en.wikipedia.beta.wmflabs.org/wiki/Dog.
* Find a footnote in the article, e.g. the , and click it.
* Use the little ^ to jump back up.
* Look for another footnote, e.g. , and click it.
* Now check the little ^ in the 5th footnote you clicked before. It's not a link any more, but text.
[x] Find the issue, fix it.
 Add a test that protects us from #regression's.
NOTE: The issue only happened with unnamed ("anonymous") ref tags that don't have a `name="…"`. These get IDs like `cite_ref-<#>` where `<#>` is the sequential number of the ref, starting from 1. Named refs on the other hand, no matter if reused or not, get IDs like `cite_ref-<name>_<#>-<use>`, where the usage count starts from 0. If a named ref is //not// reused, it's ID ends with `-0`, and the next one ending with `-1` doesn't exist. This is what [the old code](https://phabricator.wikimedia.org/rECIT85ad4513bac587b3fb176d2902dbb0308acec95d) checked. Unfortunately, the first unnamed ref will also end with `-1`, which is what confused the code.