Skip to content

Commit 80d5a75

Browse files
committed
Merge branch 'hman61-DooHTML-v0.91.7'
2 parents 943ea6a + cc20e55 commit 80d5a75

File tree

10 files changed

+85
-64
lines changed

10 files changed

+85
-64
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie"
77

88
const lenA = adjectives.length, lenB = colours.length, lenC = nouns.length
99
const DEFAULT_SIZE = 1000
10-
const SWAP_ROW = 998
11-
const EMPTY = String('')
10+
const CHILD_1 = 1
11+
const CHILD_998 = 998
1212
Doo.define(
1313
class Main extends Doo {
1414
constructor() {
@@ -51,9 +51,9 @@ Doo.define(
5151
}
5252

5353
buildData(count = DEFAULT_SIZE) {
54-
const data = []
54+
const data = new Array(count)
5555
for (let i = 0; i < count; i++) {
56-
data.push({id: this.ID++,label: adjectives[_random(lenA)] + " " + colours[_random(lenB)] + " " + nouns[_random(lenC)]})
56+
data[i] = {id: this.ID++,label: `${adjectives[_random(lenA)]} ${colours[_random(lenB)]} ${nouns[_random(lenC)]}`}
5757
}
5858
return data
5959
}
@@ -126,16 +126,16 @@ Doo.define(
126126
}
127127

128128
swapRows() {
129-
if (this.data.rows.length > SWAP_ROW) {
130-
let node1 = this.tbody.firstChild.nextSibling,
131-
swapRow = this.tbody.childNodes[SWAP_ROW],
129+
if (this.data.rows.length > CHILD_998) {
130+
let node1 = this.tbody.childNodes[CHILD_1],
131+
swapRow = this.tbody.childNodes[CHILD_998],
132132
node999 = swapRow.nextSibling,
133-
row1 = this.data.rows[1]
133+
row1 = this.data.rows[CHILD_1]
134134

135-
this.data.rows[1] = this.data.rows[SWAP_ROW];
136-
this.data.rows[SWAP_ROW] = row1
137-
138-
this.tbody.insertBefore(node1.parentNode.replaceChild(swapRow, node1), node999)
135+
this.data.rows[CHILD_1] = this.data.rows[CHILD_998];
136+
this.data.rows[CHILD_998] = row1
137+
this.tbody.insertBefore(swapRow, node1)
138+
this.tbody.insertBefore(node1, node999)
139139
}
140140
}
141141

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

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

frameworks/keyed/doohtml-dom/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.91.5-beta",
3+
"version": "0.91.7-beta",
44
"description": "DooHTML-DOM (no shadow) JS-Benchmark",
55
"main": "Main.class.js",
66
"js-framework-benchmark": {

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie"
99
const lenA = adjectives.length, lenB = colours.length, lenC = nouns.length
1010

1111
const DEFAULT_SIZE = 1000
12-
const SWAP_ROW = 998
12+
const CHILD_1 = 1
13+
const CHILD_998 = 998
14+
1315
Doo.define(
1416
class Main extends Doo {
1517
constructor() {
@@ -52,9 +54,9 @@ Doo.define(
5254
}
5355

5456
buildData(count = DEFAULT_SIZE) {
55-
const data = []
57+
const data = new Array(count)
5658
for (let i = 0; i < count; i++) {
57-
data.push({id: this.ID++,label: adjectives[_random(lenA)] + " " + colours[_random(lenB)] + " " + nouns[_random(lenC)]})
59+
data[i] = {id: this.ID++,label: `${adjectives[_random(lenA)]} ${colours[_random(lenB)]} ${nouns[_random(lenC)]}`}
5860
}
5961
return data
6062
}
@@ -127,16 +129,16 @@ Doo.define(
127129
}
128130

129131
swapRows() {
130-
if (this.data.rows.length > SWAP_ROW) {
131-
let node1 = this.tbody.firstChild.nextSibling,
132-
swapRow = this.tbody.childNodes[SWAP_ROW],
132+
if (this.data.rows.length > CHILD_998) {
133+
let node1 = this.tbody.childNodes[CHILD_1],
134+
swapRow = this.tbody.childNodes[CHILD_998],
133135
node999 = swapRow.nextSibling,
134-
row1 = this.data.rows[1]
135-
136-
this.data.rows[1] = this.data.rows[SWAP_ROW];
137-
this.data.rows[SWAP_ROW] = row1
136+
row1 = this.data.rows[CHILD_1]
138137

139-
this.tbody.insertBefore(node1.parentNode.replaceChild(swapRow, node1), node999)
138+
this.data.rows[CHILD_1] = this.data.rows[CHILD_998];
139+
this.data.rows[CHILD_998] = row1
140+
this.tbody.insertBefore(swapRow, node1)
141+
this.tbody.insertBefore(node1, node999)
140142
}
141143
}
142144

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

Lines changed: 2 additions & 2 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.91.4-beta",
3+
"version": "0.91.7-beta",
44
"description": "DooHTML JS-Benchmark",
55
"main": "Main.class.js",
66
"js-framework-benchmark": {

frameworks/non-keyed/doohtml/index.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>DooHTML</title>
5+
<title>DooHTML - (non-keyed)</title>
66
<link href="/css/currentStyle.css" rel="preload" as="style"/>
77
<link href="/css/currentStyle.css" rel="stylesheet"/>
88
<link href="./js/doo.html.min.js" rel="preload" as="script"/>
99
<script src="./js/doo.html.min.js"></script>
1010
<script type="module" src="./js/Main.class.js" defer ></script>
11+
<template id="table">
12+
<table class="table table-hover table-striped test-data">
13+
<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>
14+
</table>
15+
<link href="/css/currentStyle.css" rel="stylesheet">
16+
</template>
1117
</head>
1218
<body>
1319
<div id="main">
@@ -43,9 +49,10 @@ <h1>DooHTML - non-keyed</h1><span class="ver"></span>
4349
</div>
4450
<doo-main
4551
context="shadow"
46-
link="/css/currentStyle.css"
47-
bind="rows"
48-
template="./templates/main.html"
52+
data-key="id"
53+
data-has-html="false"
54+
data-hydrate="true"
55+
template="#table"
4956
></doo-main>
5057
</div>
5158
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>

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

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie"
88

99
const lenA = adjectives.length, lenB = colours.length, lenC = nouns.length
1010

11+
const DEFAULT_SIZE = 1000
12+
const CHILD_1 = 1
13+
const CHILD_998 = 998
1114
Doo.define(
1215
class Main extends Doo {
1316
constructor() {
1417
super(100)
15-
this.scrollTarget = '.table'
1618
this.defaultDataSet = 'rows'
1719
this.ID = 1
1820
this.data = {
@@ -32,7 +34,7 @@ Doo.define(
3234

3335
async dooAfterRender() {
3436
this.tbody = this.shadow.querySelector('#tbody')
35-
this.shadow.querySelector(this.scrollTarget).addEventListener('click', e => {
37+
this.tbody.addEventListener('click', e => {
3638
e.preventDefault()
3739
if (e.target.parentElement.matches('.remove')) {
3840
this.delete(e.target.parentElement)
@@ -50,10 +52,10 @@ Doo.define(
5052
return undefined
5153
}
5254

53-
buildData(count = 1000) {
54-
const data = [];
55+
buildData(count = DEFAULT_SIZE) {
56+
const data = new Array(count)
5557
for (let i = 0; i < count; i++) {
56-
data.push({id: this.ID++,label: adjectives[_random(lenA)] + " " + colours[_random(lenB)] + " " + nouns[_random(lenC)]})
58+
data[i] = {id: this.ID++,label: `${adjectives[_random(lenA)]} ${colours[_random(lenB)]} ${nouns[_random(lenC)]}`}
5759
}
5860
return data
5961
}
@@ -62,7 +64,7 @@ Doo.define(
6264
let row = this.getParentRow(elem)
6365
if (row) {
6466
this.tbody.removeChild(row)
65-
this.data.rows[row.getAttribute('key')] = undefined
67+
this.data.rows.splice(row.rowIndex,1)
6668
}
6769
}
6870

@@ -114,27 +116,16 @@ Doo.define(
114116
return elem.classList.contains('danger')
115117
}
116118
swapRows() {
117-
const A=1,B=998
118-
if (this.data.rows.length > B) {
119+
if (this.data.rows.length > CHILD_998) {
120+
let node1 = this.tbody.childNodes[CHILD_1],
121+
swapRow = this.tbody.childNodes[CHILD_998],
122+
node999 = swapRow.nextSibling,
123+
row1 = this.data.rows[CHILD_1]
119124

120-
let a = this.tbody.childNodes[A],
121-
b = this.tbody.childNodes[B],
122-
row1 = this.data.rows[1]
123-
124-
this.data.rows[A] = this.data.rows[B];
125-
this.data.rows[B] = row1
126-
127-
const selected1 = this.isRowSelected(a)
128-
const selected2 = this.isRowSelected(b)
129-
this.updateRow(A, this.data.rows, this.tbody)
130-
this.updateRow(B, this.data.rows, this.tbody)
131-
132-
if (selected1) {
133-
this.select(this.tbody.childNodes[B])
134-
}
135-
if (selected2) {
136-
this.select(this.tbody.childNodes[A])
137-
}
125+
this.data.rows[CHILD_1] = this.data.rows[CHILD_998];
126+
this.data.rows[CHILD_998] = row1
127+
this.tbody.insertBefore(swapRow, node1)
128+
this.tbody.insertBefore(node1, node999)
138129
}
139130
}
140131

@@ -157,5 +148,7 @@ Doo.define(
157148
}
158149
})
159150
}
160-
}
161-
)
151+
async connectedCallback() {
152+
super.connectedCallback()
153+
}
154+
})

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

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

frameworks/non-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.60.13",
3+
"version": "0.91.7",
44
"description": "DooHTML JS-Benchmark",
55
"main": "Main.class.js",
66
"js-framework-benchmark": {

0 commit comments

Comments
 (0)