refactor(core): add warning if trying to remove non-existing element

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-01-18 21:46:37 +01:00
committed by Braks
parent 07dad4b491
commit ec346c3e3b
+2
View File
@@ -123,7 +123,9 @@ export const applyChanges = <
else warn(`${isNode(change.item) ? `Node` : `Edge`} with id ${change.item.id} already exists`)
} else if (change.type === 'remove') {
const index = elements.findIndex((el) => el.id === change.id)
if (index !== -1) elements.splice(index, 1)
else warn(`Element with id ${change.id} does not exist`)
}
})