From: Scott Worley Date: Wed, 26 Jan 2022 21:00:15 +0000 (-0800) Subject: Eliminate createTask. It's part of addTask X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/ef7ebad4fdeec65f894d080e48fb43d372dec250?ds=sidebyside;hp=68a72fde2851bd9c176b8862708b71707c1d3ea1 Eliminate createTask. It's part of addTask In the spirit of maintaining the invariant: all tasks are in the DOM; no loose, floating tasks. --- diff --git a/vopamoi.ts b/vopamoi.ts index b899c71..ab06155 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -15,16 +15,13 @@ function splitN(str: string, delimiter: string, limit: number = MAX_SAFE_INTEGER const Model = { addTask: function (timestamp: string, description: string) { - document.getElementById("tasks")!.appendChild(this.createTask(timestamp, description)).focus(); - }, - - createTask: function (timestamp: string, description: string) { const task = document.createElement("div"); task.appendChild(document.createTextNode(description)); task.setAttribute("class", "task"); task.setAttribute("tabindex", "0"); task.setAttribute("data-created", timestamp); - return task; + document.getElementById("tasks")!.appendChild(task); + task.focus(); }, destroyTask: function (createTimestamp: string) {