Skip to content

Commit 654d79d

Browse files
committed
rename shouldSkipDomUpdate to shouldPlace and hoist INSERT_VNODE flag check into a variable
1 parent 27881a3 commit 654d79d

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/diff/children.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,9 @@ export function diffChildren(
128128
firstChildDom = newDom;
129129
}
130130

131-
if (
132-
childVNode._flags & INSERT_VNODE ||
133-
oldVNode._children === childVNode._children
134-
) {
135-
oldDom = insert(
136-
childVNode,
137-
oldDom,
138-
parentDom,
139-
!(childVNode._flags & INSERT_VNODE) /* shouldSkipDomUpdate */
140-
);
131+
let shouldPlace = !!(childVNode._flags & INSERT_VNODE);
132+
if (shouldPlace || oldVNode._children === childVNode._children) {
133+
oldDom = insert(childVNode, oldDom, parentDom, shouldPlace);
141134
} else if (typeof childVNode.type == 'function' && result !== UNDEFINED) {
142135
oldDom = result;
143136
} else if (newDom) {
@@ -347,10 +340,10 @@ function constructNewChildrenArray(
347340
* @param {VNode} parentVNode
348341
* @param {PreactElement} oldDom
349342
* @param {PreactElement} parentDom
350-
* @param {boolean} shouldSkipDomUpdate
343+
* @param {boolean} shouldPlace
351344
* @returns {PreactElement}
352345
*/
353-
function insert(parentVNode, oldDom, parentDom, shouldSkipDomUpdate) {
346+
function insert(parentVNode, oldDom, parentDom, shouldPlace) {
354347
// Note: VNodes in nested suspended trees may be missing _children.
355348
if (typeof parentVNode.type == 'function') {
356349
let children = parentVNode._children;
@@ -361,13 +354,13 @@ function insert(parentVNode, oldDom, parentDom, shouldSkipDomUpdate) {
361354
// children's _parent pointer to point to the newVNode (parentVNode
362355
// here).
363356
children[i]._parent = parentVNode;
364-
oldDom = insert(children[i], oldDom, parentDom, shouldSkipDomUpdate);
357+
oldDom = insert(children[i], oldDom, parentDom, shouldPlace);
365358
}
366359
}
367360

368361
return oldDom;
369362
} else if (parentVNode._dom != oldDom) {
370-
if (!shouldSkipDomUpdate) {
363+
if (shouldPlace) {
371364
if (oldDom && parentVNode.type && !oldDom.parentNode) {
372365
oldDom = getDomSibling(parentVNode);
373366
}

0 commit comments

Comments
 (0)