Skip to content

Commit

Permalink
Always initialize commitQueue & refQueue (-5 B)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Nov 1, 2023
1 parent 1cb13f5 commit 49959bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ export function getDomSibling(vnode, childIndex) {
function renderComponent(component) {
let oldVNode = component._vnode,
oldDom = oldVNode._dom,
parentDom = component._parentDom;
parentDom = component._parentDom,
commitQueue = [],
refQueue = [];

if (parentDom) {
let commitQueue = [],
refQueue = [];

const newVNode = assign({}, oldVNode);
newVNode._original = oldVNode._original + 1;

Expand Down
6 changes: 3 additions & 3 deletions src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {
childVNode._parent = newParentVNode;
childVNode._depth = newParentVNode._depth + 1;

let skewedIndex = i + skew;
const skewedIndex = i + skew;
const matchingIndex = findMatchingIndex(
childVNode,
oldChildren,
Expand All @@ -292,7 +292,7 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {
// Here, we define isMounting for the purposes of the skew diffing
// algorithm. Nodes that are unsuspending are considered mounting and we detect
// this by checking if oldVNode._original === null
let isMounting =
const isMounting =
matchingIndex === -1 ||
oldChildren[matchingIndex] == null ||
oldChildren[matchingIndex]._original === null;
Expand Down Expand Up @@ -323,7 +323,7 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {
}

// Move this VNode's DOM if the original index (matchingIndex) doesn't match
// the new skew index (i + skew) or it's a mounting component VNode
// the new skew index (i + new skew) or it's a mounting DOM VNode
if (
matchingIndex !== i + skew ||
(typeof childVNode.type != 'function' && isMounting)
Expand Down

0 comments on commit 49959bd

Please sign in to comment.