@@ -4,50 +4,48 @@ import { buildData } from './data';
44App ( new TModel ( "benchmark" , {
55 canHaveDom : false ,
66 runButton ( ) {
7- return new TModel ( 'run' , {
7+ return new TModel ( 'run' , {
88 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' ) ;
1211 }
1312 } ) ;
1413 } ,
1514 runAlotButton ( ) {
1615 return new TModel ( 'runlots' , {
1716 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' ) ;
2119 }
2220 } ) ;
2321 } ,
2422 addButton ( ) {
2523 return new TModel ( 'add' , {
2624 onClick ( ) {
27- const rows = this . getParent ( ) . findChild ( 'rows' ) ;
25+ const rows = this . getParentValue ( 'rows' ) ;
2826 rows . activateTarget ( 'buildData' , 1000 ) . activateTarget ( 'createRows' ) ;
2927 }
3028 } ) ;
3129 } ,
3230 updateButton ( ) {
3331 return new TModel ( 'update' , {
3432 onClick ( ) {
35- const rows = this . getParent ( ) . findChild ( 'rows' ) ;
36- rows . activateTarget ( 'updateEvery10thLink' ) ;
33+ const rows = this . getParentValue ( 'rows' ) ;
34+ rows . activateTarget ( 'selectLinks' ) . activateTarget ( ' updateEvery10thLink') ;
3735 }
3836 } ) ;
3937 } ,
4038 clearButton ( ) {
4139 return new TModel ( 'clear' , {
4240 onClick ( ) {
43- this . getParent ( ) . findChild ( 'rows' ) . removeAll ( ) ;
41+ this . getParentValue ( 'rows' ) . removeAll ( ) ;
4442 }
4543 } ) ;
4644 } ,
4745 swapRows ( ) {
4846 return new TModel ( 'swaprows' , {
4947 onClick ( ) {
50- const rows = this . getParent ( ) . findChild ( 'rows' ) ;
48+ const rows = this . getParentValue ( 'rows' ) ;
5149 const elementCount = rows . $dom . elementCount ( ) ;
5250 if ( elementCount > 998 ) {
5351 rows . activateTarget ( 'swap' , [ 1 , 998 ] ) ;
@@ -68,7 +66,6 @@ App(new TModel("benchmark", {
6866 return buildData ( this . _buildData ) ;
6967 } ,
7068 _createRows ( ) {
71- this . deleteTargetValue ( 'selectLinks' ) ;
7269 this . prevTargetValue . forEach ( ( data , index ) => {
7370 const $tr = this . val ( 'rowTemplate' ) . cloneTemplate ( ) ;
7471 $tr . attr ( 'data-id' , `${ index } ` ) ;
@@ -78,6 +75,9 @@ App(new TModel("benchmark", {
7875 } ) ;
7976 } ,
8077 _selectLinks ( ) {
78+ if ( ! this . isPrevTargetUpdated ( ) ) {
79+ return ( this . val ( this . key ) || [ ] ) ;
80+ }
8181 const $rows = this . $dom . queryAll ( 'tr' ) ;
8282 const links = [ ] ;
8383 for ( let i = 0 ; i < $rows . length ; i += 10 ) {
@@ -86,7 +86,7 @@ App(new TModel("benchmark", {
8686 return links ;
8787 } ,
8888 _updateEvery10thLink ( ) {
89- this . prevTargetValue . forEach ( link => link . textContent += ' !!!' )
89+ this . prevTargetValue . forEach ( link => link . textContent += ' !!!' ) ;
9090 } ,
9191 _swap ( ) {
9292 const rowElements = this . _swap . map ( id => this . $dom . query ( `[data-id="${ id } "]` ) ) ;
0 commit comments