Consider this wikitext snippet below:
==h1== foo <translate> bar ==h2== baz </translate> booz
As part of section wrapping, the DOM is restructured .. for example what used to be a linear list of children of body will get split up into different top-level section nodes. On occasion, if content from adjacent sections come from the same extension, we need to reconcile this conflict between the section boundary and the extension boundary such that the extension wrapper isn't broken up.
When this happens, we might hoist the data-mw and extension wrapper information to a section tag. But since there might be child nodes before / after the extension content that is also part of the section, the extension wrapper on the section tags has to represent this additional content that gets pulled into the new extension-content boundary.
To capture this, we are introducing an extPrefix and extSuffix property to the data-mw object added to the extension wrapper. In turn, this means that serialization has to be aware of this.
Right now, we are not exposing this ugliness in the HTML spec. This phab task is to figure out if there is a way we can avoid this messiness somehow.