diff --git a/package.json b/package.json index 99b577a..8617215 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alfama", - "version": "0.3.20", + "version": "0.3.21", "author": "Abhishiv Saxena", "license": "MIT", "description": "Fine-grained reactive library with no compiler, no magic, and no virtual DOM", diff --git a/src/stdlib/Each/index.tsx b/src/stdlib/Each/index.tsx index 704421e..c0583ff 100644 --- a/src/stdlib/Each/index.tsx +++ b/src/stdlib/Each/index.tsx @@ -75,7 +75,22 @@ export const Each: ( 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 };