Skip to content

Commit

Permalink
fix(patch): no extra parameter needed
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Oct 23, 2021
1 parent 75fe710 commit 74114dc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"@typescript-eslint/eslint-plugin": "^5.1.0",
"@typescript-eslint/parser": "^4.33.0",
"benchmark": "^2.1.4",
"eslint": "^8.0.1",
"eslint": "^8.1.0",
"eslint-config-prettier": "^8.3.0",
"github-markdown-css": "^5.0.0",
"glob": "^7.2.0",
Expand Down
42 changes: 21 additions & 21 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 2 additions & 16 deletions src/drivers/children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ export const childrenDriver = (
);
break;
case VDeltaOperationTypes.UPDATE:
patch(
<DOMNode>child,
newVNodeChildren![deltaPosition],
oldVNodeChildren[deltaPosition],
workStack,
undefined,
false,
);
patch(<DOMNode>child, newVNodeChildren![deltaPosition], oldVNodeChildren[deltaPosition]);
break;
case VDeltaOperationTypes.DELETE:
workStack.push(() => el.removeChild(child));
Expand All @@ -61,14 +54,7 @@ export const childrenDriver = (
// Interates backwards, so in case a childNode is destroyed, it will not shift the nodes
// and break accessing by index
for (let i = oldVNodeChildren.length - 1; i >= 0; --i) {
patch(
<DOMNode>el.childNodes[i],
newVNodeChildren[i],
oldVNodeChildren[i],
workStack,
undefined,
true,
);
patch(<DOMNode>el.childNodes[i], newVNodeChildren[i], oldVNodeChildren[i]);
}
}

Expand Down
11 changes: 4 additions & 7 deletions src/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ export const compose =
prevVNode?: VNode,
workStack: VTask[] = [],
commit?: VCommit,
isRoot = true,
): DOMNode => {
const finish = (element: DOMNode): DOMNode => {
if (isRoot) {
workStack.push(() => {
if (!prevVNode) element[OLD_VNODE_FIELD] = newVNode;
});
flushWorkStack(workStack, commit);
}
workStack.push(() => {
if (!prevVNode) element[OLD_VNODE_FIELD] = newVNode;
});
flushWorkStack(workStack, commit);
return element;
};

Expand Down

0 comments on commit 74114dc

Please sign in to comment.