(vnode, domNode, oldChildren, newChildren, projectionOptions)
| 521 | var createDom; |
| 522 | var updateDom; |
| 523 | var updateChildren = function (vnode, domNode, oldChildren, newChildren, projectionOptions) { |
| 524 | if (oldChildren === newChildren) { |
| 525 | return false; |
| 526 | } |
| 527 | oldChildren = oldChildren || emptyArray; |
| 528 | newChildren = newChildren || emptyArray; |
| 529 | var oldChildrenLength = oldChildren.length; |
| 530 | var newChildrenLength = newChildren.length; |
| 531 | var transitions = projectionOptions.transitions; |
| 532 | var oldIndex = 0; |
| 533 | var newIndex = 0; |
| 534 | var i; |
| 535 | var textUpdated = false; |
| 536 | while (newIndex < newChildrenLength) { |
| 537 | var oldChild = oldIndex < oldChildrenLength ? oldChildren[oldIndex] : undefined; |
| 538 | var newChild = newChildren[newIndex]; |
| 539 | if (oldChild !== undefined && same(oldChild, newChild)) { |
| 540 | textUpdated = updateDom(oldChild, newChild, projectionOptions) || textUpdated; |
| 541 | oldIndex++; |
| 542 | } else { |
| 543 | var findOldIndex = findIndexOfChild(oldChildren, newChild, oldIndex + 1); |
| 544 | if (findOldIndex >= 0) { |
| 545 | // Remove preceding missing children |
| 546 | for (i = oldIndex; i < findOldIndex; i++) { |
| 547 | nodeToRemove(oldChildren[i], transitions); |
| 548 | checkDistinguishable(oldChildren, i, vnode, 'removed'); |
| 549 | } |
| 550 | textUpdated = updateDom(oldChildren[findOldIndex], newChild, projectionOptions) || textUpdated; |
| 551 | oldIndex = findOldIndex + 1; |
| 552 | } else { |
| 553 | // New child |
| 554 | createDom(newChild, domNode, oldIndex < oldChildrenLength ? oldChildren[oldIndex].domNode : undefined, projectionOptions); |
| 555 | nodeAdded(newChild, transitions); |
| 556 | checkDistinguishable(newChildren, newIndex, vnode, 'added'); |
| 557 | } |
| 558 | } |
| 559 | newIndex++; |
| 560 | } |
| 561 | if (oldChildrenLength > oldIndex) { |
| 562 | // Remove child fragments |
| 563 | for (i = oldIndex; i < oldChildrenLength; i++) { |
| 564 | nodeToRemove(oldChildren[i], transitions); |
| 565 | checkDistinguishable(oldChildren, i, vnode, 'removed'); |
| 566 | } |
| 567 | } |
| 568 | return textUpdated; |
| 569 | }; |
| 570 | var addChildren = function (domNode, children, projectionOptions) { |
| 571 | if (!children) { |
| 572 | return; |
no test coverage detected