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:
<span class="mw-cite-backlink"> <span class="mw-cite-up-arrow">^</span> <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> </span>
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 [5], and click it.
- Use the little ^ to jump back up.
- Look for another footnote, e.g. [6], and click it.
- Now check the little ^ in the 5th footnote you clicked before. It's not a link any more, but text.
Acceptance criteria:
- Find the issue, fix it.
- Add a test that protects us from Regression's. -> now tracked in T217767
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 checked. Unfortunately, the first unnamed ref will also end with -1, which is what confused the code.