fix(dom_renderer): moveNodeAfterSiblings should not detach the reference node

Fixes #5077
Closes #5759
This commit is contained in:
Tobias Bosch 2015-12-09 14:44:18 -08:00
parent 693d9dce5d
commit edcb34dc9f
1 changed files with 11 additions and 4 deletions

View File

@ -365,11 +365,18 @@ function resolveInternalDomFragment(fragmentRef: RenderFragmentRef): Node[] {
}
function moveNodesAfterSibling(sibling, nodes) {
if (nodes.length > 0 && isPresent(DOM.parentElement(sibling))) {
for (var i = 0; i < nodes.length; i++) {
DOM.insertBefore(sibling, nodes[i]);
var parent = DOM.parentElement(sibling);
if (nodes.length > 0 && isPresent(parent)) {
var nextSibling = DOM.nextSibling(sibling);
if (isPresent(nextSibling)) {
for (var i = 0; i < nodes.length; i++) {
DOM.insertBefore(nextSibling, nodes[i]);
}
} else {
for (var i = 0; i < nodes.length; i++) {
DOM.appendChild(parent, nodes[i]);
}
}
DOM.insertBefore(nodes[0], sibling);
}
}