Previously replaceChildRangeLowLevel took the new child range as a Node* New. New was expected to have siblings attached already, and thus it was interpreted as a range. Additionally, the role of New and its siblings were expected to be set prior to calling the function. As a result the New argument broke the invariant New->Parent == nullptr <=> New->Role == Detached, at call site. We change the signature of replaceChildRangeLowLevel to take instead an ArrayRef<std::pair<Node*, NodeRole>>, and thus move the burden of setting siblings and roles from the user to the member function.
Moreover, replaceChildRangeLowLevel returns now a vector of the replaced range, following the "law of useful returns". Previously, in
order to reuse the replaced elements the user needed to get pointers to those elements and before calling the function.
We also fixed some minor bugs in addAfter, and added more asserts to the new replaceChildRangeLowLevel.