@@ -190,19 +190,18 @@ export class CTable {
190190 }
191191
192192 let sortClass = this . styles . sortNone ;
193- const isReverse = / ^ - / . test ( this . defaultSortCol ) ;
193+ const isDescending = / ^ - / . test ( this . defaultSortCol ) ;
194194 const defaultSortCol = this . defaultSortCol . replace ( / ^ - / , '' ) ;
195195
196+ // I think the classes are backwards
197+ const asc = this . styles . sortAsc ;
198+ const desc = this . styles . sortDesc ;
199+
196200 if ( col . colHeadName === defaultSortCol ) {
201+ const reversedColumn : boolean = Boolean ( col . reverseSort ) ;
197202 const { reverseSort = false } = col ;
198203
199- if ( isReverse ) {
200- sortClass = this . styles . sortDesc ;
201- } else if ( reverseSort ) {
202- sortClass = col . reverseSort ? this . styles . sortDesc : this . styles . sortAsc ;
203- } else {
204- sortClass = this . reverseSort ? this . styles . sortDesc : this . styles . sortAsc ;
205- }
204+ sortClass = isDescending ? desc : asc ;
206205 }
207206
208207 col . sortClass = sortClass ;
@@ -217,21 +216,26 @@ export class CTable {
217216 } ) ;
218217
219218 let reverse : boolean ;
219+ const reversedColumn : boolean = Boolean ( col . reverseSort ) ;
220+
221+ const asc = this . styles . sortAsc ;
222+ const desc = this . styles . sortDesc ;
223+
220224 // Use reverseSort property of column or reverse-sort binding of table (in that order)
221225 // to determine initial sort. After initial sort, just toggle.
222226 if ( col . sortClass === this . styles . sortNone ) {
223- if ( typeof col . reverseSort === 'boolean' ) {
224- col . sortClass = col . reverseSort ? this . styles . sortDesc : this . styles . sortAsc ;
225- reverse = col . reverseSort ;
227+ if ( reversedColumn ) {
228+ col . sortClass = desc ;
229+ reverse = true ;
226230 } else {
227- col . sortClass = this . reverseSort ? this . styles . sortDesc : this . styles . sortAsc ;
228- reverse = this . reverseSort ;
231+ col . sortClass = asc ;
232+ reverse = false ;
229233 }
230- } else if ( col . sortClass === this . styles . sortAsc ) {
231- col . sortClass = this . styles . sortDesc ;
234+ } else if ( col . sortClass === asc ) {
235+ col . sortClass = desc ;
232236 reverse = true ;
233237 } else {
234- col . sortClass = this . styles . sortAsc ;
238+ col . sortClass = asc ;
235239 reverse = false ;
236240 }
237241 if ( this . actions && this . actions . sortColumn ) {
0 commit comments