My test case is relatively straightforward. All I do is to copy paste (with Ctrl+C and Ctrl+V) a sub-reference a few times so I have a few copies I can edit. When I edit the last one, keep the checkbox selected, and click apply, the browser hangs for a full minute.
{F70216418}
==== Issue
- To split up a sub-ref from it's reuses we introduced `ve.dm.MWReferenceModel.copySubReference`
- In there we create an empty `MWReferenceModel` and have a step to copy the `Document` from the editing to that new model
- We use `ve.dm.Document.cloneWithData` to do that, but it seems that this will also copy the original `InternalList` to the ref's document and when the two are merged the original document grows.
See https://gerrit.wikimedia.org/g/mediawiki/extensions/Cite/+/3d0bd2958735b479be93ffbeecb47c86109e504a/modules/ve-cite/ve.dm.MWReferenceModel.js#81