Skip to content

Commit

Permalink
Rename _lastDomChildSibling to _nextDom (#2297)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins authored Feb 3, 2020
1 parent 47110de commit a0c6009
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion mangle.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"cname": 6,
"props": {
"$_depth": "__b",
"$_lastDomChildSibling": "__d",
"$_nextDom": "__d",
"$_dirty": "__d",
"$_force": "__e",
"$_nextState": "__s",
Expand Down
8 changes: 4 additions & 4 deletions src/create-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export function createVNode(type, props, key, ref) {
_parent: null,
_depth: 0,
_dom: null,
// _lastDomChildSibling must be initialized to undefined b/c it will eventually
// _nextDom must be initialized to undefined b/c it will eventually
// be set to dom.nextSibling which can return `null` and it is important
// to be able to distinguish between an uninitialized _lastDomChildSibling and
// a _lastDomChildSibling that has been set to `null`
_lastDomChildSibling: undefined,
// to be able to distinguish between an uninitialized _nextDom and
// a _nextDom that has been set to `null`
_nextDom: undefined,
_component: null,
constructor: undefined
};
Expand Down
16 changes: 8 additions & 8 deletions src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@ export function diffChildren(
}

let nextDom;
if (childVNode._lastDomChildSibling !== undefined) {
if (childVNode._nextDom !== undefined) {
// Only Fragments or components that return Fragment like VNodes will
// have a non-undefined _lastDomChildSibling. Continue the diff from the sibling
// have a non-undefined _nextDom. Continue the diff from the sibling
// of last DOM child of this child VNode
nextDom = childVNode._lastDomChildSibling;
nextDom = childVNode._nextDom;

// Eagerly cleanup _lastDomChildSibling. We don't need to persist the value because
// Eagerly cleanup _nextDom. We don't need to persist the value because
// it is only used by `diffChildren` to determine where to resume the diff after
// diffing Components and Fragments. Once we store it the nextDOM local var, we
// can clean up the property
childVNode._lastDomChildSibling = undefined;
childVNode._nextDom = undefined;
} else if (
excessDomChildren == oldVNode ||
newDom != oldDom ||
Expand Down Expand Up @@ -188,14 +188,14 @@ export function diffChildren(

if (typeof newParentVNode.type == 'function') {
// Because the newParentVNode is Fragment-like, we need to set it's
// _lastDomChildSibling property to the nextSibling of its last child DOM node.
// _nextDom property to the nextSibling of its last child DOM node.
//
// `oldDom` contains the correct value here because if the last child
// is a Fragment-like, then oldDom has already been set to that child's _lastDomChildSibling.
// is a Fragment-like, then oldDom has already been set to that child's _nextDom.
// If the last child is a DOM VNode, then oldDom will be set to that DOM
// node's nextSibling.

newParentVNode._lastDomChildSibling = oldDom;
newParentVNode._nextDom = oldDom;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ export function unmount(vnode, parentVNode, skipRemove) {
skipRemove = (dom = vnode._dom) != null;
}

// Must be set to `undefined` to properly clean up `_lastDomChildSibling`
// Must be set to `undefined` to properly clean up `_nextDom`
// for which `null` is a valid value. See comment in `create-element.js`
vnode._dom = vnode._lastDomChildSibling = undefined;
vnode._dom = vnode._nextDom = undefined;

if ((r = vnode._component) != null) {
if (r.componentWillUnmount) {
Expand Down
2 changes: 1 addition & 1 deletion src/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface VNode<P = {}> extends preact.VNode<P> {
/**
* The last dom child of a Fragment, or components that return a Fragment
*/
_lastDomChildSibling: PreactElement | Text | null;
_nextDom: PreactElement | Text | null;
_component: Component | null;
constructor: undefined;
}
Expand Down

0 comments on commit a0c6009

Please sign in to comment.