From 8a67b011f02d76f2142c85aed46bc2c36f9f0e99 Mon Sep 17 00:00:00 2001 From: foxdonut Date: Sat, 7 May 2016 11:23:13 +0000 Subject: [PATCH] Fix initial todos. --- todomvc/common/store.js | 3 +-- todomvc/vanillajs/view.js | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/todomvc/common/store.js b/todomvc/common/store.js index 70df6a87..a7e90cc4 100644 --- a/todomvc/common/store.js +++ b/todomvc/common/store.js @@ -23,8 +23,7 @@ ref.todoStorage = { loadAll: function() { - return JSON.parse(localStorage.getItem(STORAGE_KEY) || - "[{\"id\":1,\"title\":\"meiosis\",\"completed\":false}]"); + return JSON.parse(localStorage.getItem(STORAGE_KEY) || "[]"); }, saveTodo: function(todo) { var todos = ref.todoStorage.loadAll(); diff --git a/todomvc/vanillajs/view.js b/todomvc/vanillajs/view.js index 1b98b549..816b4c0c 100644 --- a/todomvc/vanillajs/view.js +++ b/todomvc/vanillajs/view.js @@ -7,8 +7,7 @@ }; var main = function(model, _actions) { - // FIXME - var renderedTodos = (model.todos || []).map(renderTodo).join(""); + var renderedTodos = model.todos.map(renderTodo).join(""); return "
" + " " + @@ -38,11 +37,9 @@ }; var footer = function(model) { - // FIXME - var todos = (model.todos || []); var notCompleted = function(todo) { return !todo.completed; }; - var itemsLeft = todos.filter(notCompleted).length; - var itemsLeftText = todos.length > 0 ? + var itemsLeft = model.todos.filter(notCompleted).length; + var itemsLeftText = model.todos.length > 0 ? (String(itemsLeft) + " item" + (itemsLeft === 1 ? "" : "s") + " left") : ""; return "