]> git.scottworley.com Git - vopamoi/commitdiff
Eliminate createTask. It's part of addTask
authorScott Worley <scottworley@scottworley.com>
Wed, 26 Jan 2022 21:00:15 +0000 (13:00 -0800)
committerScott Worley <scottworley@scottworley.com>
Thu, 27 Jan 2022 20:21:55 +0000 (12:21 -0800)
In the spirit of maintaining the invariant: all tasks are in the DOM; no
loose, floating tasks.

vopamoi.ts

index b899c7144d6acb5d6c8594b49c80805f1362e9ca..ab0615593b321d90b574a3d04539a99d45a3a700 100644 (file)
@@ -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) {