From 9e79bdbb90ffcb5929f76a4fb6860ed6396ac9de Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 25 Jan 2022 11:43:08 -0800 Subject: [PATCH 1/1] No MVMVC; DOM *is* the model. --- vopamoi.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/vopamoi.ts b/vopamoi.ts index 5967c7d..cfa1186 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -1,19 +1,12 @@ -var tasks: string[] = []; - -function createViewTask(task: string) { - const viewTask = document.createElement("div"); - viewTask.appendChild(document.createTextNode(task)); - viewTask.setAttribute("tabindex", "0"); - return viewTask; -} - -function updateView() { - tasks.forEach((t) => document.getElementById(t) || document.body.appendChild(createViewTask(t))); +function createTask(description: string) { + const task = document.createElement("div"); + task.appendChild(document.createTextNode(description)); + task.setAttribute("tabindex", "0"); + return task; } -function addTask(task: string) { - tasks.push(task); - updateView(); +function addTask(description: string) { + document.body.appendChild(createTask(description)); } function browserCreateTask(form: any) { -- 2.44.1