[FIX] playground: not all completed is deleted

Before this fix, not all completed tasks are deleted when clicking clear
completed button because we are looping to a mutated array. Looping thru
a copy of the mutated array fixes this problem.
This commit is contained in:
Joseph Caburnay
2020-01-09 09:32:40 +01:00
committed by Géry Debongnie
parent b7b0e38fca
commit 0c9c5b877b
+1 -1
View File
@@ -455,7 +455,7 @@ const actions = {
todo.completed = !todo.completed;
},
clearCompleted({ state, dispatch }) {
for (let todo of state.todos) {
for (let todo of state.todos.slice()) {
if (todo.completed) {
dispatch("removeTodo", todo.id);
}