When a node that would normally contain data-mw info is in first encapsulation position, we drop all that info in favour of the template info.
This is fine for serialization, since the template would take precedence, but other uses of the HTML may still have a need for it.
In particular, the media post-processing pass from T153080 wants to make use of options stored there,
An earlier version of Cite extension touched on it as well,
but that was refactored out in,
So, the question is if we should unconditionally stop clobbering the previously existing data-mw info and provide access to it in the output HTML in some other systematic way.