@@ -57,6 +57,7 @@ Doo.define(
57
57
}
58
58
return data
59
59
}
60
+
60
61
getIndex ( row ) {
61
62
let idx = this . data . rows . findIndex ( ( item , i ) => {
62
63
if ( item . id === row . key ) {
@@ -69,8 +70,8 @@ Doo.define(
69
70
delete ( elem ) {
70
71
let row = this . getParentRow ( elem )
71
72
if ( row ) {
72
- this . tbody . removeChild ( row )
73
73
let idx = this . getIndex ( row )
74
+ this . tbody . removeChild ( row )
74
75
if ( idx !== undefined ) {
75
76
this . data . rows . splice ( idx , 1 )
76
77
}
@@ -79,20 +80,20 @@ Doo.define(
79
80
}
80
81
81
82
run ( ) {
82
- this . clear ( )
83
83
this . data . rows = this . buildData ( )
84
+ this . tbody . textContent = ''
84
85
this . renderTable ( )
85
-
86
86
}
87
87
88
88
add ( ) {
89
+ let startRow = this . data . rows . length
89
90
this . data . rows = this . data . rows . concat ( this . buildData ( ) )
90
- this . renderTable ( this . data . rows )
91
+ this . renderTable ( this . data . rows , startRow )
91
92
}
92
93
93
94
runLots ( ) {
94
- this . clear ( )
95
95
this . data . rows = this . buildData ( 10000 )
96
+ this . tbody . textContent = ''
96
97
this . renderTable ( )
97
98
}
98
99
@@ -107,15 +108,11 @@ Doo.define(
107
108
this . selectedRow . classList . remove ( 'danger' )
108
109
this . selectedRow = undefined
109
110
}
110
- this . toggleSelect ( this . getParentRow ( elem ) )
111
- }
111
+ let row = this . getParentRow ( elem )
112
112
113
- toggleSelect ( row ) {
114
113
if ( row ) {
115
114
row . classList . toggle ( 'danger' )
116
- if ( row . classList . contains ( 'danger' ) ) {
117
- this . selectedRow = row
118
- }
115
+ this . selectedRow = row
119
116
}
120
117
}
121
118
0 commit comments