My first guess is that Tidy is the culprit. Try the input
<ref>foo</ref><ref><div>bar</div></ref><ref><table><tr><td>baz</td></tr></table></ref>
<references />
on Wikipedia.
The first reference is correctly wrapped in a <span class="reference-text">, in the second reference this span is moved inside the <div>, in the third it is missing completely.
Version: unspecified
Severity: normal