Skip to content

Commit

Permalink
Use copied VNode as newVNode instead of oldVNode when rerendering (#4171
Browse files Browse the repository at this point in the history
)
  • Loading branch information
andrewiggins committed Oct 28, 2023
1 parent 2019d65 commit 8e5eac5
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,39 +120,35 @@ export function getDomSibling(vnode, childIndex) {
* @param {Component} component The component to rerender
*/
function renderComponent(component) {
let vnode = component._vnode,
oldDom = vnode._dom,
let oldVNode = component._vnode,
oldDom = oldVNode._dom,
parentDom = component._parentDom;

if (parentDom) {
let commitQueue = [],
refQueue = [];
const oldVNode = assign({}, vnode);
oldVNode._original = vnode._original + 1;

if (oldVNode._children) {
oldVNode._children.forEach(child => {
if (child) child._parent = oldVNode;
});
}
const newVNode = assign({}, oldVNode);
newVNode._original = oldVNode._original + 1;

diff(
parentDom,
vnode,
newVNode,
oldVNode,
component._globalContext,
parentDom.ownerSVGElement !== undefined,
vnode._hydrating != null ? [oldDom] : null,
oldVNode._hydrating != null ? [oldDom] : null,
commitQueue,
oldDom == null ? getDomSibling(vnode) : oldDom,
vnode._hydrating,
oldDom == null ? getDomSibling(oldVNode) : oldDom,
oldVNode._hydrating,
refQueue
);

commitRoot(commitQueue, vnode, refQueue);
newVNode._parent._children[newVNode._index] = newVNode;
commitRoot(commitQueue, newVNode, refQueue);

if (vnode._dom != oldDom) {
updateParentDomPointers(vnode);
if (newVNode._dom != oldDom) {
updateParentDomPointers(newVNode);
}
}
}
Expand Down

0 comments on commit 8e5eac5

Please sign in to comment.