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