]> git.scottworley.com Git - vopamoi/blobdiff - vopamoi.ts
Do more filtering in faster browser-native code
[vopamoi] / vopamoi.ts
index a6f85f2dc53864577c98445de5b7606b80eb4ac7..cbb9af23d308527302aedc4fc40493cf297f90a0 100644 (file)
@@ -80,8 +80,8 @@ const Model = {
   },
 
   hasTag: function (task: Element, tag: string): Element | null {
   },
 
   hasTag: function (task: Element, tag: string): Element | null {
-    for (const child of task.children) {
-      if (child.classList.contains("tag") && child.textContent === tag) {
+    for (const child of task.getElementsByClassName("tag")) {
+      if (child.textContent === tag) {
         return child;
       }
     }
         return child;
       }
     }
@@ -284,7 +284,7 @@ function BrowserUI() {
       input.removeEventListener("blur", this.completeTagEdit);
       task.removeChild(input);
       task.focus();
       input.removeEventListener("blur", this.completeTagEdit);
       task.removeChild(input);
       task.focus();
-      if (!Model.hasTag(task, newTagName)) {
+      if (resolution === CommitOrAbort.Commit && newTagName && !Model.hasTag(task, newTagName)) {
         ui.addTag(task.getAttribute("data-created")!, newTagName);
         lastTagNameEntered = newTagName;
       }
         ui.addTag(task.getAttribute("data-created")!, newTagName);
         lastTagNameEntered = newTagName;
       }