Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb98215

Browse files
committed
Merge branch 'hman61-DooHTML-keyed-0.60.2'
2 parents 824ae27 + 7cba150 commit cb98215

File tree

4 files changed

+31
-37
lines changed

4 files changed

+31
-37
lines changed

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

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
'use strict';
1+
'use strict'
22

3-
const _random = ((max) => {
4-
return Math.round(Math.random()*1000)%max;
5-
})
3+
const _random = max => Math.random() * max | 0
64

7-
const adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"];
8-
const colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
9-
const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"];
5+
const adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"]
6+
const colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"]
7+
const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"]
108

119
const lenA = adjectives.length, lenB = colours.length, lenC = nouns.length
1210

@@ -35,25 +33,25 @@ Doo.define(
3533
async dooAfterRender() {
3634
this.tbody = this.shadow.querySelector('#tbody')
3735
this.shadow.querySelector(this.scrollTarget).addEventListener('click', e => {
38-
e.preventDefault();
36+
e.preventDefault()
3937
if (e.target.parentElement.matches('.remove')) {
40-
this.delete(e.target.parentElement);
38+
this.delete(e.target.parentElement)
4139
} else if (e.target.tagName === 'A') {
42-
this.select(e.target);
40+
this.select(e.target)
4341
}
44-
});
42+
})
4543
}
4644

4745
getParentRow(elem) {
4846
while (elem) {
4947
if (elem.tagName === "TR") {return elem}
50-
elem = elem.parentNode;
48+
elem = elem.parentNode
5149
}
52-
return undefined;
50+
return undefined
5351
}
5452

5553
buildData(count = 1000) {
56-
const data = [];
54+
const data = []
5755
for (let i = 0; i < count; i++) {
5856
data.push({id: this.ID++,label: adjectives[_random(lenA)] + " " + colours[_random(lenB)] + " " + nouns[_random(lenC)]})
5957
}
@@ -69,36 +67,32 @@ Doo.define(
6967
}
7068

7169
run() {
70+
this.clear()
7271
this.data.rows = this.buildData()
73-
this.tbody.textContent = ''
7472
this.renderTable()
7573
}
7674

7775
add() {
78-
let startRow = this.data.rows.length
7976
this.data.rows = this.data.rows.concat(this.buildData())
80-
this.appendData(this.tbody, startRow)
77+
this.renderTable(this.data.rows)
8178
}
8279

8380
runLots() {
81+
this.clear()
8482
this.data.rows = this.buildData(10000)
85-
this.tbody.textContent = ''
8683
this.renderTable()
8784
}
8885

89-
update() {
90-
let tr = this.tbody.querySelectorAll('tr')
86+
update(e) {
9187
for (let i=0, len = this.data.rows.length;i<len;i+=10) {
92-
this.data.rows[i].label += ' !!!';
93-
tr[i].childNodes[1].childNodes[0].textContent = this.data.rows[i].label
88+
this.tbody.childNodes[i].childNodes[1].childNodes[0].innerText = this.data.rows[i].label += ' !!!'
9489
}
9590
}
9691

9792
select(elem) {
9893
if (this.selectedRow) {
9994
this.selectedRow.classList.remove('danger')
10095
this.selectedRow = undefined
101-
// return should toggle IMO
10296
}
10397
let row = this.getParentRow(elem)
10498
if (row) {
@@ -117,8 +111,8 @@ Doo.define(
117111
let node1 = this.tbody.childNodes[1]
118112
let node2 = this.tbody.childNodes[998]
119113

120-
let row1 = this.data.rows[1];
121-
this.data.rows[1] = this.data.rows[998];
114+
let row1 = this.data.rows[1]
115+
this.data.rows[1] = this.data.rows[998]
122116
this.data.rows[998] = row1
123117

124118
this.tbody.insertBefore(node2, node1)
@@ -129,19 +123,19 @@ Doo.define(
129123

130124
addEventListeners() {
131125
document.getElementById("main").addEventListener('click', e => {
132-
e.preventDefault();
126+
e.preventDefault()
133127
if (e.target.matches('#runlots')) {
134-
this.runLots(e);
128+
this.runLots()
135129
} else if (e.target.matches('#run')) {
136-
this.run(e);
130+
this.run()
137131
} else if (e.target.matches('#add')) {
138-
this.add(e);
132+
this.add()
139133
} else if (e.target.matches('#update')) {
140-
this.update();
134+
this.update()
141135
} else if (e.target.matches('#clear')) {
142-
this.clear();
136+
this.clear()
143137
} else if (e.target.matches('#swaprows')) {
144-
this.swapRows();
138+
this.swapRows()
145139
}
146140
})
147141
}

frameworks/keyed/doohtml/js/doo.html.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/doohtml/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-framework-benchmark-doohtml",
3-
"version": "0.30.8",
3+
"version": "0.60.2",
44
"description": "DooHTML JS-Benchmark",
55
"main": "Main.class.js",
66
"js-framework-benchmark": {

frameworks/keyed/doohtml/templates/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<template>
33
<table class="table table-hover table-striped test-data">
44
<link href="${link}" rel="stylesheet">
5-
<tbody id="tbody"><tr bind="rows" key="{{i()}}"><td class="col-md-1">{{id}}</td><td class="col-md-4"><a>{{label}}</a></td><td class="col-md-1"><a class="remove"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td><td class="col-md-6"></td></tr></tbody>
5+
<tbody id="tbody"><tr bind="rows"><td class="col-md-1">{{id}}</td><td class="col-md-4"><a>{{label}}</a></td><td class="col-md-1"><a class="remove"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td><td class="col-md-6"></td></tr></tbody>
66
</table>
77
</template>

0 commit comments

Comments
 (0)