Skip to content

Commit 630bf77

Browse files
committed
improve checking target id and switch back clearing rows
1 parent d8241fd commit 630bf77

File tree

1 file changed

+11
-11
lines changed
  • frameworks/keyed/vanillajs-2/src

1 file changed

+11
-11
lines changed

frameworks/keyed/vanillajs-2/src/Main.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,31 @@ class Main {
8383

8484
document.getElementById("main").addEventListener("click", (e) => {
8585
//console.log("listener",e);
86-
if (e.target.matches("#add")) {
86+
if (e.target.id == "add") {
8787
e.stopPropagation();
8888
//console.log("add");
8989
this.add();
90-
} else if (e.target.matches("#run")) {
90+
} else if (e.target.id == "run") {
9191
e.stopPropagation();
9292
//console.log("run");
9393
this.run();
94-
} else if (e.target.matches("#update")) {
94+
} else if (e.target.id == "update") {
9595
e.stopPropagation();
9696
//console.log("update");
9797
this.update();
98-
} else if (e.target.matches("#runlots")) {
98+
} else if (e.target.id == "runlots") {
9999
e.stopPropagation();
100100
//console.log("runLots");
101101
this.runLots();
102-
} else if (e.target.matches("#clear")) {
102+
} else if (e.target.id == "clear") {
103103
e.stopPropagation();
104104
//console.log("clear");
105105
this.clear();
106-
} else if (e.target.matches("#swaprows")) {
106+
} else if (e.target.id == "swaprows") {
107107
e.stopPropagation();
108108
//console.log("swapRows");
109109
this.swapRows();
110-
} else if (e.target.matches(".remove")) {
110+
} else if (e.target.id == ".remove") {
111111
let id = getParentId(e.target);
112112
let idx = this.data.findIndex((row) => row.id === id);
113113
//console.log("delete",idx);
@@ -166,7 +166,7 @@ class Main {
166166
// var cNode = tbody.cloneNode(false);
167167
// tbody.parentNode.replaceChild(cNode ,tbody);
168168
// ~212 msecs
169-
// this.tbody.textContent = "";
169+
this.tbody.textContent = "";
170170

171171
// ~236 msecs
172172
// var rangeObj = new Range();
@@ -176,9 +176,9 @@ class Main {
176176
// var last;
177177
// while (last = tbody.lastChild) tbody.removeChild(last);
178178

179-
const clone = this.tbody.cloneNode();
180-
this.tbody.remove();
181-
this.table.insertBefore((this.tbody = clone), null);
179+
// const clone = this.tbody.cloneNode();
180+
// this.tbody.remove();
181+
// this.table.insertBefore((this.tbody = clone), null);
182182
}
183183
runLots() {
184184
this.removeAllRows();

0 commit comments

Comments
 (0)