Кнопка паузы не меняется

Кнопка play/stop не меняется при клике на нее, когда я хочу сохранить результат в localStorage и вывожу на страницу.

Но если убрать вывод на страницу, все работает, но положение кнопки обнуляется. Кто-то поможет?

Вот мой код:

const form = document.querySelector('#form');
const input = document.querySelector('#input');
const board = document.querySelector('#board');

// create task list
let taskList = [];

let taskItems = [];

if (!localStorage.taskList) {
  taskList = [];
} else {
  taskList = JSON.parse(localStorage.getItem('taskList'));
}

// create task
class Task {
  constructor(description) {
    this.description = description;
    this.status = false;
  }
}

// add task event
form.addEventListener('submit', (e) => {
  e.preventDefault();
  taskList.push(new Task(input.value));
  input.value = '';

  addTaskToHtml();
  updateLocalStorage();
});

// functions:
// update local stptage
function updateLocalStorage() {
  localStorage.setItem('taskList', JSON.stringify(taskList));
}

// create task template
function createTask(item, idx) {
  return `
    <div class="task__item">
      <div class="task__item--name">${item.description}</div>
      <div class="task__item--tracking">
        <span id="timer" class="task__item--tracking--timer">00:00:00</span>
        <span id="startStop" class="task__item--tracking--start-stop" onclick="complete(${idx})"></span>
        <span id="deleteTask" class="task__item--tracking--delele" onclick="deleteTask(${idx})"><i class="far fa-trash-alt"></i></span>
      </div>
    </div>
  `;
}

// add task to html
function addTaskToHtml() {
  board.innerHTML = '';

  if (taskList.length > 0) {
    taskList.forEach((item, idx) => {
      board.innerHTML += createTask(item, idx);
    });

    taskItems = document.querySelectorAll('.task__item');
    taskItems.forEach((item) => {
      item.classList.add('paused');
    });
  }
}

addTaskToHtml();

// delete Task
function deleteTask(idx) {
  taskList.splice(idx, 1);

  updateLocalStorage();
  addTaskToHtml();
}

// complete
function complete(idx) {
  taskList[idx].status = !taskList[idx].status;

  if (taskList[idx].status) {
    taskItems[idx].classList.add('paused');
  } else {
    taskItems[idx].classList.remove('paused');
  }

  updateLocalStorage();
  addTaskToHtml();
  console.log(taskItems[idx]);
}
* {
  padding: 0;
  margin: 0;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  height: 100vh;
  margin: 0;
  font-family: 'Roboto', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: #000;
  background-color: #f4f4f6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

a {
  text-decoration: none;
  font-weight: 500;
}

/* CONTAINER */
.container {
  width: 100%;
  max-width: 1170px;
  margin: 0 auto;
  padding: 0 15px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
}

.app {
  text-align: center;
  width: 560px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  margin-top: 150px;
}

.app__title {
  color: #b0a3a7;
  font-size: 46px;
  font-weight: 300;
}

.app__title span {
  color: #000;
  font-weight: 700;
}

.app__add {
  margin-top: 50px;
  width: 100%;
}

.app__tasks {
  margin-top: 25px;
  text-align: left;
}

.form {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
}

.form__input {
  width: 100%;
  padding: 15px 25px;
  outline: none;
  border: 0;
  border: 1px solid #b0a3a7;
  border-radius: 25px;
  background-color: #f4f4f6;
  font-size: 16px;
  color: #000;
}

.form__btn {
  margin-top: 25px;
  height: 40px;
  width: 40px;
  line-height: 40px;
  font-size: 30px;
  color: #4d4d4d;
  border: 1px solid #b0a3a7;
  background-color: #f4f4f6;
  cursor: pointer;
}

.task__item {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  padding: 25px;
  margin-top: 5px;
  background: #e6e6eb;
  border-radius: 15px;
  color: #2e8b57;
}

.task__item--tracking {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
}

.task__item--tracking span {
  margin-left: 20px;
  cursor: pointer;
  font-size: 20px;
}

.task__item--tracking span:nth-child(1) {
  margin-left: 0;
  font-size: 16px;
  cursor: auto;
}

.task__item--tracking span:nth-child(2) {
  border: 0;
  background: transparent;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
  width: 0;
  height: 20px;
  border-color: transparent transparent transparent #000;
  -webkit-transition: 100ms all ease;
  transition: 100ms all ease;
  cursor: pointer;
  border-style: solid;
  border-width: 10px 0 10px 15px;
}

.task__item--tracking span:nth-child(3) {
  color: #be0909;
  font-size: 19px;
}

.task__item.paused .task__item--tracking--start-stop {
  height: 15px;
  border-style: double;
  border-width: 0px 0px 0px 15px;
}
/*# sourceMappingURL=style.css.map */
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Task Tracker</title>
    <!-- GOOGLE ICONS -->
    <link
      rel="stylesheet"
      href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
      integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p"
      crossorigin="anonymous"
    />

    <!-- GOOGLE FONTS -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;500;700&display=swap"
      rel="stylesheet"
    />

    <!-- CSS -->
    <link rel="stylesheet" href="assets/css/style.css" />
  </head>
  <body>
    <div class="container">
      <div class="app">
        <div class="button"></div>
        <div class="app__title"><span>Tasks</span> Lists</div>
        <div class="app__add">
          <form id="form" class="form" action="/">
            <input id="input" class="form__input" type="text" />
            <button id="addBtn" class="form__btn">+</button>
          </form>
        </div>

        <div id="board" class="app__tasks">
          <!--           <div class="task__item">
            <div class="task__item--name">name</div>
            <div class="task__item--tracking">
              <span id="timer" class="task__item--tracking--timer"
                >00:00:00</span
              >
              <span id="startStop" class="task__item--tracking--start-stop">
              </span>
              <span id="deleteTask" class="task__item--tracking--delele"
                ><i class="far fa-trash-alt"></i
              ></span>
            </div>
          </div> -->
        </div>
      </div>
    </div>

    <!-- JavaScript -->
    <script src="./assets/js/app.js"></script>
  </body>
</html>


Ответы (0 шт):