Last modified: 2014-09-04 21:41:03 UTC
The serializer does a lot of checks against previous/next sibling and first/last child. The problem in selser-mode is that DOMDiff inserts mw:DiffMarker metas to signal places where the DOM has been modified compared to the original DOM. So, naive checks against previous/next sibling and first/last child will fail. In reality, those checks have to pretend as if the diff-marker metas don't exist. Currently, we do have helper functions that do these checks by ignoring them (previousNonDeletedSibling, etc). However, there are still places in the serializer where first/last child checks could be broken, and whenever new code is added to the serializer, we have to account for this fact. An alternative way of encoding this diff information could be considered to prevent this ugliness and to guard against inadvertent errors introduced by our current style of recording diffs in the DOM. In the past, Gabriel and I have discussed on such solution where we introduce this diff-marker information in an attribute of the parent node. This attribute could record a diff flag for each of the children and would be queried wherever diff information is required. However, doing this would be a fair bit of work and cleanup and hence is a non-trivial task. But, it could potentially be a useful cleanup. Recording it here so we consider this in our copious free time.