@@ -57,6 +57,7 @@ Doo.define(
5757 }
5858 return data
5959 }
60+
6061 getIndex ( row ) {
6162 let idx = this . data . rows . findIndex ( ( item , i ) => {
6263 if ( item . id === row . key ) {
@@ -69,8 +70,8 @@ Doo.define(
6970 delete ( elem ) {
7071 let row = this . getParentRow ( elem )
7172 if ( row ) {
72- this . tbody . removeChild ( row )
7373 let idx = this . getIndex ( row )
74+ this . tbody . removeChild ( row )
7475 if ( idx !== undefined ) {
7576 this . data . rows . splice ( idx , 1 )
7677 }
@@ -79,20 +80,20 @@ Doo.define(
7980 }
8081
8182 run ( ) {
82- this . clear ( )
8383 this . data . rows = this . buildData ( )
84+ this . tbody . textContent = ''
8485 this . renderTable ( )
85-
8686 }
8787
8888 add ( ) {
89+ let startRow = this . data . rows . length
8990 this . data . rows = this . data . rows . concat ( this . buildData ( ) )
90- this . renderTable ( this . data . rows )
91+ this . renderTable ( this . data . rows , startRow )
9192 }
9293
9394 runLots ( ) {
94- this . clear ( )
9595 this . data . rows = this . buildData ( 10000 )
96+ this . tbody . textContent = ''
9697 this . renderTable ( )
9798 }
9899
@@ -107,15 +108,11 @@ Doo.define(
107108 this . selectedRow . classList . remove ( 'danger' )
108109 this . selectedRow = undefined
109110 }
110- this . toggleSelect ( this . getParentRow ( elem ) )
111- }
111+ let row = this . getParentRow ( elem )
112112
113- toggleSelect ( row ) {
114113 if ( row ) {
115114 row . classList . toggle ( 'danger' )
116- if ( row . classList . contains ( 'danger' ) ) {
117- this . selectedRow = row
118- }
115+ this . selectedRow = row
119116 }
120117 }
121118
0 commit comments