Background: As discovered in T389929: Save edited main reference content back to inline main+details, the rendered reflist being sent by VE when saving the page contains an outdated rendering, the same as what VE was opened with. Content of newly-edited references is only carried through the reflist tag data-mw.
Problem: This makes it extremely difficult for Parsoid to extract the updated content, and especially affects our main+details use case because the main ref content needs to be used ahead of processing the reflist.
Suggested implementation: VE should instead render the reflist from scratch so that all <li> contain freshly transformed content. Each li should include an standardized element ID corresponding to the mainBody of a main+details subref.
Especially consider how to handle a template-produced reflist. Perhaps all transclusion-produced content should be omitted, and any missing reflists should be added at the end of the document, including reflists with non-default group names.
Dev notes:
- The VE DOM sent back after editing can only be tested by writing QUnit cases. Here's a case that must be adjusted to reflect the work in this task: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cite/+/1144571/2/tests/qunit/ve-cite/ve.dm.citeExample.js