Skip to content

Commit

Permalink
Merge 89a0df5 into a109fb9
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Jun 26, 2019
2 parents a109fb9 + 89a0df5 commit 63a3aba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/component.js
Expand Up @@ -107,10 +107,11 @@ export function getDomSibling(vnode, childIndex) {
for (; childIndex < vnode._children.length; childIndex++) {
sibling = vnode._children[childIndex];

if (sibling != null) {
return typeof sibling.type !== 'function'
? sibling._dom
: getDomSibling(sibling, 0);
if (sibling != null && sibling._dom != null) {
// Since updateParentDomPointers keeps _dom pointer correct,
// we can rely on _dom to tell us if this subtree contains a
// rendered DOM node, and what the first rendered DOM node is
return sibling._dom;
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/diff/children.js
Expand Up @@ -2,6 +2,7 @@ import { diff, unmount, applyRef } from './index';
import { coerceToVNode } from '../create-element';
import { EMPTY_OBJ, EMPTY_ARR } from '../constants';
import { removeNode } from '../util';
import { getDomSibling } from '../component';

/**
* Diff the children of a virtual node
Expand Down Expand Up @@ -36,14 +37,14 @@ export function diffChildren(parentDom, newParentVNode, oldParentVNode, context,
// for this purpose, because `null` is a valid value for `oldDom` which can mean to skip to this logic
// (e.g. if mounting a new tree in which the old DOM should be ignored (usually for Fragments).
if (oldDom == EMPTY_OBJ) {
oldDom = null;
if (excessDomChildren!=null) {
if (excessDomChildren != null) {
oldDom = excessDomChildren[0];
}
else if (oldChildrenLength) {
oldDom = getDomSibling(oldParentVNode, 0);
}
else {
for (i = 0; !oldDom && i < oldChildrenLength; i++) {
oldDom = oldChildren[i] && oldChildren[i]._dom;
}
oldDom = null;
}
}

Expand Down

0 comments on commit 63a3aba

Please sign in to comment.