Skip to content

Commit

Permalink
improve each
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishiv committed Jun 24, 2024
1 parent d29b195 commit fc9d6d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alfama",
"version": "0.3.20",
"version": "0.3.21",
"author": "Abhishiv Saxena<[email protected]>",
"license": "MIT",
"description": "Fine-grained reactive library with no compiler, no magic, and no virtual DOM",
Expand Down
15 changes: 15 additions & 0 deletions src/stdlib/Each/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,22 @@ export const Each: <T extends ArrayOrObject>(
const { registry, root } = reifyTree(renderContext, el, parentStep);
addNode(renderContext, parentStep, root);
} else if (data.name === "pop") {
const previousChildren = [...parentStep.children];
const firstNode = previousChildren[0];
if (firstNode) removeNode(renderContext, firstNode);
} else if (data.name === "splice") {
const previousChildren = [...parentStep.children];
const [startIndex, deleteCount, ...items] = data.args as [
number,
number,
...any
];
const nodesToRemove = previousChildren.slice(
startIndex,
startIndex + deleteCount
);
nodesToRemove.forEach((n) => removeNode(renderContext, n));
// todo: add nodes at proper position
}
};
const task = { path, observor };
Expand Down

0 comments on commit fc9d6d4

Please sign in to comment.