Skip to content

Commit

Permalink
save bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jun 28, 2023
1 parent e65cc81 commit 504f025
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
14 changes: 6 additions & 8 deletions src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ export function diffChildren(
newDom = childVNode._dom;

if ((j = childVNode.ref) && oldVNode.ref != j) {
if (!refs) refs = [];
if (oldVNode.ref) refs.push(oldVNode.ref, null, childVNode);
refs.push(j, childVNode._component || newDom, childVNode);
if (oldVNode.ref) {
if (!refs) refs = [];
refs.push(oldVNode.ref, null, childVNode);
}
refQueue.push(j, childVNode._component || newDom, childVNode);
}

if (newDom != null) {
Expand Down Expand Up @@ -249,11 +251,7 @@ export function diffChildren(
// Set refs only after unmount
if (refs) {
for (let i = 0; i < refs.length; i++) {
if (refs[i + 1]) {
refQueue.push(refs[i], refs[++i], refs[++i]);
} else {
applyRef(refs[i], refs[++i], refs[++i]);
}
applyRef(refs[i], refs[++i], refs[++i]);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ export function unmount(vnode, parentVNode, skipRemove) {

if ((r = vnode.ref)) {
if (!r.current || r.current === vnode._dom) {
console.log('applying', r, 'null');
applyRef(r, null, parentVNode);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/browser/refs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,9 @@ describe('refs', () => {
rerender();
expect(calls).to.deep.equal([
'removing ref from two',
'adding ref to one',
'adding ref to two',
'adding ref to three',
'adding ref to one'
'adding ref to three'
]);
});
});

0 comments on commit 504f025

Please sign in to comment.