The current implementation of keeping pointers to refs, so that, when inserting the references section, we can go back and mark up certain kinds of errors that are only known at that time, doesn't really work for embedded content since we can't keep those pointers live.
A fix could be to instead do a walk of the dom looking for all the refs associated with a specific reference group. That would allow us to peek inside embedded content.
See https://gerrit.wikimedia.org/r/c/mediawiki/services/parsoid/+/631860 and https://gerrit.wikimedia.org/r/c/mediawiki/services/parsoid/+/635899