@@ -34,9 +34,9 @@ const SORT_DIRECTIONS = [SORT_DIRECTION_ASC, SORT_DIRECTION_DESC, SORT_DIRECTION
34
34
// --- Props ---
35
35
36
36
export const props = {
37
- labelSortAsc : makeProp ( PROP_TYPE_STRING , 'Click to sort Ascending ' ) ,
37
+ labelSortAsc : makeProp ( PROP_TYPE_STRING , 'Click to sort ascending ' ) ,
38
38
labelSortClear : makeProp ( PROP_TYPE_STRING , 'Click to clear sorting' ) ,
39
- labelSortDesc : makeProp ( PROP_TYPE_STRING , 'Click to sort Descending ' ) ,
39
+ labelSortDesc : makeProp ( PROP_TYPE_STRING , 'Click to sort descending ' ) ,
40
40
noFooterSorting : makeProp ( PROP_TYPE_BOOLEAN , false ) ,
41
41
noLocalSorting : makeProp ( PROP_TYPE_BOOLEAN , false ) ,
42
42
// Another prop that should have had a better name
@@ -254,37 +254,38 @@ export const sortingMixin = Vue.extend({
254
254
'aria-sort' : ariaSort
255
255
}
256
256
} ,
257
+ // A label to be placed in an `.sr-only` element in the header cell
257
258
sortTheadThLabel ( key , field , isFoot ) {
258
- // A label to be placed in an `.sr-only` element in the header cell
259
+ // No label if not a sortable table
259
260
if ( ! this . isSortable || ( isFoot && this . noFooterSorting ) ) {
260
- // No label if not a sortable table
261
261
return null
262
262
}
263
- const sortable = field . sortable
264
- // The correctness of these labels is very important for screen-reader users.
263
+ const { localSortBy, localSortDesc, labelSortAsc, labelSortDesc } = this
264
+ const { sortable } = field
265
+ // The correctness of these labels is very important for screen reader users
265
266
let labelSorting = ''
266
267
if ( sortable ) {
267
- if ( this . localSortBy === key ) {
268
- // currently sorted sortable column.
269
- labelSorting = this . localSortDesc ? this . labelSortAsc : this . labelSortDesc
268
+ if ( localSortBy === key ) {
269
+ // Currently sorted sortable column
270
+ labelSorting = localSortDesc ? labelSortAsc : labelSortDesc
270
271
} else {
271
- // Not currently sorted sortable column.
272
+ // Not currently sorted sortable column
272
273
// Not using nested ternary's here for clarity/readability
273
- // Default for ariaLabel
274
- labelSorting = this . localSortDesc ? this . labelSortDesc : this . labelSortAsc
275
- // Handle sortDirection setting
274
+ // Default for `aria-label`
275
+ labelSorting = localSortDesc ? labelSortDesc : labelSortAsc
276
+ // Handle ` sortDirection` setting
276
277
const sortDirection = this . sortDirection || field . sortDirection
277
278
if ( sortDirection === SORT_DIRECTION_ASC ) {
278
- labelSorting = this . labelSortAsc
279
+ labelSorting = labelSortAsc
279
280
} else if ( sortDirection === SORT_DIRECTION_DESC ) {
280
- labelSorting = this . labelSortDesc
281
+ labelSorting = labelSortDesc
281
282
}
282
283
}
283
284
} else if ( ! this . noSortReset ) {
284
285
// Non sortable column
285
- labelSorting = this . localSortBy ? this . labelSortClear : ''
286
+ labelSorting = localSortBy ? this . labelSortClear : ''
286
287
}
287
- // Return the sr-only sort label or null if no label
288
+ // Return the `. sr-only` sort label or ` null` if no label
288
289
return trim ( labelSorting ) || null
289
290
}
290
291
}
0 commit comments