Skip to content

Commit b3bdc0c

Browse files
committed
Merge branch 'master' of https://github.com/hville/js-framework-benchmark into hville-master
2 parents 11c4794 + 99cdf95 commit b3bdc0c

File tree

7 files changed

+88
-158
lines changed

7 files changed

+88
-158
lines changed

frameworks/keyed/attodom/index.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
/*eslint indent: ["warn", 2, { "VariableDeclarator": 2 }]*/
22

3-
var el = require('attodom/el'),
4-
core = require('attodom/core'),
5-
Store = require('./src/store'),
6-
menu = require('./src/menu'),
7-
table = require('./src/table')
3+
var Store = require('./src/store'),
4+
View = require('./src/view')
85

9-
core.store = new Store
10-
core.update()
6+
var view = View(new Store)
7+
view.update()
118

12-
document.body.appendChild(
13-
el('div', {id: 'main'},
14-
el('div', {class: 'container'},
15-
menu,
16-
table,
17-
el('span', {class: 'preloadicon glyphicon glyphicon-remove', 'aria-hidden': ''})
18-
)
19-
)
20-
)
9+
document.body.appendChild(view)

frameworks/keyed/attodom/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "js-framework-benchmark-attodom-v0.5.2",
3-
"version": "0.1.0",
4-
"description": "Benchmark for attoDom 0.5.2",
2+
"name": "js-framework-benchmark-attodom-v0.9.0",
3+
"version": "0.9.0",
4+
"description": "Benchmark for attoDom 0.9.0",
55
"js-framework-benchmark": {
66
"frameworkVersionFromPackage": "attodom"
77
},
@@ -22,6 +22,6 @@
2222
"uglify-js": "3.0.12"
2323
},
2424
"dependencies": {
25-
"attodom": "0.6.1"
25+
"attodom": "0.9.0"
2626
}
2727
}

frameworks/keyed/attodom/src/create-row.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

frameworks/keyed/attodom/src/menu.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

frameworks/keyed/attodom/src/table.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

frameworks/keyed/attodom/src/time.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

frameworks/keyed/attodom/src/view.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*eslint indent: ["warn", 2, { "VariableDeclarator": 2 }]*/
2+
var h = require('attodom/el'),
3+
list = require('attodom/list'),
4+
t = require('attodom/text')
5+
6+
var TITLE = 'attodom v0.9.0'
7+
8+
module.exports = function(store) {
9+
function clickHandlerMenu(e) {
10+
var key = e.target.id
11+
if (key) {
12+
e.preventDefault()
13+
store[key === 'runlots' ? 'runLots' : key === 'swaprows' ? 'swapRows' : key]()
14+
rows.update(store.data)
15+
}
16+
}
17+
function updateRow(v) {
18+
this.$label.data = v.label
19+
this.className = (this.id === store.selected) ? 'danger' : ''
20+
}
21+
function clickHandlerSelect(e) {
22+
e.preventDefault()
23+
store.select(this.parentNode.id)
24+
rows.update(store.data)
25+
}
26+
function clickHandlerDelete(e) {
27+
e.preventDefault()
28+
store.delete(+this.parentNode.id)
29+
rows.update(store.data)
30+
}
31+
32+
var rows = list('id', function(rec) {
33+
var attr = {id: rec.id, update: updateRow, $label: t(rec.label)}
34+
return h('tr', attr,
35+
h('td', {class: 'col-md-1'}, rec.id),
36+
h('td', {class: 'col-md-4', onclick: clickHandlerSelect},
37+
h('a', {class: 'lbl'}, attr.$label)
38+
),
39+
h('td', {class: 'col-md-1', onclick: clickHandlerDelete},
40+
h('a', {class: 'remove'},
41+
h('span', {class: 'glyphicon glyphicon-remove remove', 'aria-hidden': ''})
42+
)
43+
),
44+
h('td', {class: 'col-md-6'})
45+
)
46+
})
47+
48+
return h('div', {id: 'main', update: function() { rows.update(store.data) }},
49+
h('div', {class: 'container'},
50+
h('div', {class: 'jumbotron'},
51+
h('div', {class: 'row'},
52+
h('div', {class: 'col-md-6'},
53+
h('h1', TITLE)
54+
),
55+
h('div', {class: 'col-md-6'},
56+
h('div', {class: 'row', onclick: clickHandlerMenu},
57+
button('run', 'Create 1,000 rows'),
58+
button('runlots', 'Create 10,000 rows'), //TODO error
59+
button('add', 'Append 1,000 rows'),
60+
button('update', 'Update every 10th row'),
61+
button('clear', 'Clear'),
62+
button('swaprows', 'Swap Rows')
63+
)
64+
)
65+
)
66+
),
67+
h('table', {class: 'table table-hover table-striped test-data'},
68+
h('tbody', {id: 'tbody'}, rows)
69+
),
70+
h('span', {class: 'preloadicon glyphicon glyphicon-remove', 'aria-hidden': ''})
71+
)
72+
)
73+
}
74+
75+
function button(id, tx) {
76+
return h('div', {class: 'col-sm-6 smallpad'},
77+
h('button', {id: id, class: 'btn btn-primary btn-block', type: 'button'}, tx)
78+
)
79+
}

0 commit comments

Comments
 (0)