classList is a member of Element. todo
is the iterator of todos
, which was initialized as
const todos = todoList.childNodes;
childNodes is a NodeList
, which has Node items inside of it. Node is an interface, one of its implementations is Element
. So, the troubling item is a Node
, but not an Element
. I would find out what it is if I were you. A simple fix would be
todo.classList && todo.classList.contains("completed")
at both occasions, but I would dig deeper to find out what the issue is if I were you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…