Skip to content

Commit 7834912

Browse files
committed
Merge branch 'DooHTML-v0.30.5' of https://github.com/hman61/js-framework-benchmark into hman61-DooHTML-v0.30.5
2 parents 5caeed6 + e44565e commit 7834912

File tree

3 files changed

+34
-37
lines changed

3 files changed

+34
-37
lines changed

frameworks/keyed/doohtml/index.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44
<meta charset="UTF-8">
55
<title>DooHTML</title>
66
<link href="/css/currentStyle.css" rel="stylesheet"/>
7-
<!-- <script src="https://cdn.jsdelivr.net/gh/hman61/[email protected]/dist/doo.html.min.js"></script> -->
8-
<script type="module" src="./js/doo.html.min.js"></script>
9-
<!-- <script src="./js/doo.html.min.js"></script> -->
7+
<script src="./js/doo.html.min.js"></script>
108
<script type="module" src="./js/Main.class.js"></script>
119
</head>
1210

1311
<body>
1412

1513
<div id="main">
1614
<div class="container">
17-
<div class="jumbotron">
18-
<div class="row">
19-
<div class="col-md-6">
20-
<h1>DooHTML</h1>
21-
</div>
15+
<div class="jumbotron">
16+
<div class="row">
17+
<div class="col-md-6">
18+
<h1>DooHTML - keyed</h1><span class="ver"></span>
19+
</div>
2220
<div class="col-md-6">
2321
<div class="row">
2422
<div class="col-sm-6 smallpad">

frameworks/keyed/doohtml/js/Main.class.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
'use strict';
22

3-
let startTime = {};
4-
let tot = []
5-
6-
73
const _random = ((max) => {
84
return Math.round(Math.random()*1000)%max;
95
})
@@ -32,9 +28,9 @@ Doo.define(
3228
this.swaprows = this.swapRows.bind(this)
3329
this.addEventListeners()
3430
this.selectedRow = undefined
35-
document.querySelector(".jumbotron H1").innerHTML += ` ${Doo.version} (keyed)`
31+
document.querySelector(".ver").innerHTML += ` ${Doo.version} (keyed)`
3632
document.title += ` ${Doo.version} (keyed)`
37-
}
33+
}
3834

3935
async dooAfterRender() {
4036
this.tbody = this.shadow.querySelector('#tbody')
@@ -47,8 +43,8 @@ Doo.define(
4743
}
4844
});
4945
}
50-
51-
getParentRow(elem) {
46+
47+
getParentRow(elem) {
5248
while (elem) {
5349
if (elem.tagName === "TR") {return elem}
5450
elem = elem.parentNode;
@@ -63,7 +59,7 @@ Doo.define(
6359
}
6460
return data
6561
}
66-
62+
6763
delete(elem) {
6864
let row = this.getParentRow(elem)
6965
if (row) {
@@ -74,18 +70,20 @@ Doo.define(
7470

7571
run() {
7672
this.data.rows = this.buildData()
77-
this.renderAll()
73+
this.tbody.textContent = ''
74+
this.renderTable()
7875
}
7976

8077
add() {
8178
let len = this.data.rows.length
8279
this.data.rows = this.data.rows.concat(this.buildData())
83-
this.appendData(this.data.rows, len)
80+
this.appendData(this.data.rows, len, 1000)
8481
}
8582

8683
runLots() {
87-
this.data.rows = this.buildData(10000);
88-
this.renderAll()
84+
this.data.rows = this.buildData(10000)
85+
this.tbody.textContent = ''
86+
this.renderTable()
8987
}
9088

9189
update() {
@@ -111,32 +109,33 @@ Doo.define(
111109

112110
clear() {
113111
this.data.rows = []
114-
this.tbody.textContent = ''
112+
this.tbody.innerHTML = ''
115113
}
116114

117115
swapRows() {
118116
if (this.data.rows.length>10) {
119-
let tr = this.tbody.querySelectorAll('tr')
120-
let swapNodeIdx = Math.min(tr.length - 2, 998)
121-
let node1 = tr[1].cloneNode(true)
122-
let node2 = tr[swapNodeIdx].cloneNode(true)
123-
let tmp = this.data.rows[1]
124-
this.data.rows[1] = this.data.rows[swapNodeIdx];
125-
this.data.rows[swapNodeIdx] = tmp;
126-
this.tbody.replaceChild(node2, tr[1])
127-
this.tbody.replaceChild(node1, tr[swapNodeIdx])
117+
let node1 = this.tbody.childNodes[1]
118+
let node2 = this.tbody.childNodes[998]
119+
120+
let row1 = this.data.rows[1];
121+
this.data.rows[1] = this.data.rows[998];
122+
this.data.rows[998] = row1
123+
124+
this.tbody.insertBefore(node2, node1)
125+
this.tbody.insertBefore(node1, this.tbody.childNodes[999])
126+
128127
}
129128
}
130129

131130
addEventListeners() {
132131
document.getElementById("main").addEventListener('click', e => {
133132
e.preventDefault();
134133
if (e.target.matches('#runlots')) {
135-
this.runLots();
134+
this.runLots(e);
136135
} else if (e.target.matches('#run')) {
137-
this.run();
136+
this.run(e);
138137
} else if (e.target.matches('#add')) {
139-
this.add();
138+
this.add(e);
140139
} else if (e.target.matches('#update')) {
141140
this.update();
142141
} else if (e.target.matches('#clear')) {

0 commit comments

Comments
 (0)