4. Bugs fixing - marcinkopka/todo-list-app GitHub Wiki

Four bugs has been found in application code:


1) Bug which not allows adding new todos to the list (simple typo bug).

LOCATION: controller.js line 95

Controller.prototype.adddItem = function (title) {

has been changed into

Controller.prototype.addItem = function (title) {

2) Bug which may leads to potential conflict between duplicate IDs (ID for new todos has been generated randomly which could leads to create duplicated ID's).

LOCATION: store.js starting from line 84

var newId = "";
var charset = "0123456789";
for (var i = 0; i < 6; i++) {
  newId += charset.charAt(Math.floor(Math.random() * charset.length));
}

has been changed into

var newId = Date.now();

3) Console log displayed message when user delete todo (unnessesary code and console log).

LOCATION: controller.js starting from line 165

items.forEach(function(item) {
  if (item.id === id) {
    console.log("Element with ID: " + id + " has been removed.");
  }
);

Peace of code above has been removed


4) Missing id in input tag for toggle-all label (label is binded together with an id of HTML element) which prevent toggle all todos to completed works properly.

LOCATION: index.html line 16

<input class="toggle-all" type="checkbox">

has been changed into

<input id="toggle-all" class="toggle-all" type="checkbox">