Skip to content

Commit 4d40e96

Browse files
JoviDeCroockali-garajianAli Garajian
authored
Backport some v11 optimizations (#4967)
* refactor(children): remove redundant assignment to childVNode (#4951) * refactor(children): remove redundant assignment to childVNode * refactor(children): use key instead of childVNode.key --------- Co-authored-by: Ali Garajian <[email protected]> * refactor(diff): no need to reset props and context when creating component (#4954) * refactor(children): remove redundant assignment to childVNode * refactor(children): use key instead of childVNode.key * refactor(diff): no need to reset props and context when creating component --------- Co-authored-by: Ali Garajian <[email protected]> * refactor(children): remove redundant assignment to oldVNode (#4956) Co-authored-by: Ali Garajian <[email protected]> * refactor(diff): set oldProps default value on declaration (#4959) --------- Co-authored-by: Ali Garajian <[email protected]> Co-authored-by: Ali Garajian <[email protected]>
1 parent 7b74b40 commit 4d40e96

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/diff/children.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ function constructNewChildrenArray(
218218
childVNode._original
219219
);
220220
} else {
221-
childVNode = newParentVNode._children[i] = childVNode;
221+
newParentVNode._children[i] = childVNode;
222222
}
223223

224224
const skewedIndex = i + skew;
@@ -235,7 +235,6 @@ function constructNewChildrenArray(
235235
remainingOldChildren
236236
));
237237

238-
oldVNode = NULL;
239238
if (matchingIndex != -1) {
240239
oldVNode = oldChildren[matchingIndex];
241240
remainingOldChildren--;
@@ -426,7 +425,7 @@ function findMatchingIndex(
426425
remainingOldChildren > (matched ? 1 : 0);
427426

428427
if (
429-
(oldVNode === NULL && childVNode.key == null) ||
428+
(oldVNode === NULL && key == null) ||
430429
(matched && key == oldVNode.key && type == oldVNode.type)
431430
) {
432431
return skewedIndex;

src/diff/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ export function diff(
112112
}
113113
if (provider) provider.sub(c);
114114

115-
c.props = newProps;
116115
if (!c.state) c.state = {};
117-
c.context = componentContext;
118116
c._globalContext = globalContext;
119117
isNew = c._dirty = true;
120118
c._renderCallbacks = [];
@@ -417,7 +415,7 @@ function diffElementNodes(
417415
isHydrating,
418416
refQueue
419417
) {
420-
let oldProps = oldVNode.props;
418+
let oldProps = oldVNode.props || EMPTY_OBJ;
421419
let newProps = newVNode.props;
422420
let nodeType = /** @type {string} */ (newVNode.type);
423421
/** @type {any} */
@@ -487,8 +485,6 @@ function diffElementNodes(
487485
// If excessDomChildren was not null, repopulate it with the current element's children:
488486
excessDomChildren = excessDomChildren && slice.call(dom.childNodes);
489487

490-
oldProps = oldVNode.props || EMPTY_OBJ;
491-
492488
// If we are in a situation where we are not hydrating but are using
493489
// existing DOM (e.g. replaceNode) we should read the existing DOM
494490
// attributes to diff them

0 commit comments

Comments
 (0)