@@ -4,50 +4,48 @@ import { buildData } from './data';
4
4
App ( new TModel ( "benchmark" , {
5
5
canHaveDom : false ,
6
6
runButton ( ) {
7
- return new TModel ( 'run' , {
7
+ return new TModel ( 'run' , {
8
8
onClick ( ) {
9
- const rows = this . getParent ( ) . findChild ( 'rows' ) ;
10
- rows . removeAll ( ) ;
11
- rows . activateTarget ( 'buildData' , 1000 ) . activateTarget ( 'createRows' ) ;
9
+ const rows = this . getParentValue ( 'rows' ) ;
10
+ rows . removeAll ( ) . activateTarget ( 'buildData' , 1000 ) . activateTarget ( 'createRows' ) ;
12
11
}
13
12
} ) ;
14
13
} ,
15
14
runAlotButton ( ) {
16
15
return new TModel ( 'runlots' , {
17
16
onClick ( ) {
18
- const rows = this . getParent ( ) . findChild ( 'rows' ) ;
19
- rows . removeAll ( ) ;
20
- rows . activateTarget ( 'buildData' , 10000 ) . activateTarget ( 'createRows' ) ;
17
+ const rows = this . getParentValue ( 'rows' ) ;
18
+ rows . removeAll ( ) . activateTarget ( 'buildData' , 10000 ) . activateTarget ( 'createRows' ) ;
21
19
}
22
20
} ) ;
23
21
} ,
24
22
addButton ( ) {
25
23
return new TModel ( 'add' , {
26
24
onClick ( ) {
27
- const rows = this . getParent ( ) . findChild ( 'rows' ) ;
25
+ const rows = this . getParentValue ( 'rows' ) ;
28
26
rows . activateTarget ( 'buildData' , 1000 ) . activateTarget ( 'createRows' ) ;
29
27
}
30
28
} ) ;
31
29
} ,
32
30
updateButton ( ) {
33
31
return new TModel ( 'update' , {
34
32
onClick ( ) {
35
- const rows = this . getParent ( ) . findChild ( 'rows' ) ;
36
- rows . activateTarget ( 'updateEvery10thLink' ) ;
33
+ const rows = this . getParentValue ( 'rows' ) ;
34
+ rows . activateTarget ( 'selectLinks' ) . activateTarget ( ' updateEvery10thLink') ;
37
35
}
38
36
} ) ;
39
37
} ,
40
38
clearButton ( ) {
41
39
return new TModel ( 'clear' , {
42
40
onClick ( ) {
43
- this . getParent ( ) . findChild ( 'rows' ) . removeAll ( ) ;
41
+ this . getParentValue ( 'rows' ) . removeAll ( ) ;
44
42
}
45
43
} ) ;
46
44
} ,
47
45
swapRows ( ) {
48
46
return new TModel ( 'swaprows' , {
49
47
onClick ( ) {
50
- const rows = this . getParent ( ) . findChild ( 'rows' ) ;
48
+ const rows = this . getParentValue ( 'rows' ) ;
51
49
const elementCount = rows . $dom . elementCount ( ) ;
52
50
if ( elementCount > 998 ) {
53
51
rows . activateTarget ( 'swap' , [ 1 , 998 ] ) ;
@@ -68,7 +66,6 @@ App(new TModel("benchmark", {
68
66
return buildData ( this . _buildData ) ;
69
67
} ,
70
68
_createRows ( ) {
71
- this . deleteTargetValue ( 'selectLinks' ) ;
72
69
this . prevTargetValue . forEach ( ( data , index ) => {
73
70
const $tr = this . val ( 'rowTemplate' ) . cloneTemplate ( ) ;
74
71
$tr . attr ( 'data-id' , `${ index } ` ) ;
@@ -78,6 +75,9 @@ App(new TModel("benchmark", {
78
75
} ) ;
79
76
} ,
80
77
_selectLinks ( ) {
78
+ if ( ! this . isPrevTargetUpdated ( ) ) {
79
+ return ( this . val ( this . key ) || [ ] ) ;
80
+ }
81
81
const $rows = this . $dom . queryAll ( 'tr' ) ;
82
82
const links = [ ] ;
83
83
for ( let i = 0 ; i < $rows . length ; i += 10 ) {
@@ -86,7 +86,7 @@ App(new TModel("benchmark", {
86
86
return links ;
87
87
} ,
88
88
_updateEvery10thLink ( ) {
89
- this . prevTargetValue . forEach ( link => link . textContent += ' !!!' )
89
+ this . prevTargetValue . forEach ( link => link . textContent += ' !!!' ) ;
90
90
} ,
91
91
_swap ( ) {
92
92
const rowElements = this . _swap . map ( id => this . $dom . query ( `[data-id="${ id } "]` ) ) ;
0 commit comments