From root cause investigation of T233815: html2wt: TypeError in ConstrainedText.php (comments on https://gerrit.wikimedia.org/r/597889):
DSR is computed on the DOM that already has had its content fostered and in the general case, we cannot now accurately assign DSR offsets on this since it is now in a different place than where it showed up.
To accommodate it, we'll have to make a bunch of changes (1) accurately gather information about the wikitext range that generated the fostered content -- which is simple in some cases, but not always. Mostly we haven't thought about this problem (2) apply DSR computation recursively on the fostered content by treating it as its own DOM tree.