@@ -34,9 +34,9 @@ const SORT_DIRECTIONS = [SORT_DIRECTION_ASC, SORT_DIRECTION_DESC, SORT_DIRECTION
3434// --- Props ---
3535
3636export const props = {
37- labelSortAsc : makeProp ( PROP_TYPE_STRING , 'Click to sort Ascending ' ) ,
37+ labelSortAsc : makeProp ( PROP_TYPE_STRING , 'Click to sort ascending ' ) ,
3838 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 ' ) ,
4040 noFooterSorting : makeProp ( PROP_TYPE_BOOLEAN , false ) ,
4141 noLocalSorting : makeProp ( PROP_TYPE_BOOLEAN , false ) ,
4242 // Another prop that should have had a better name
@@ -254,37 +254,38 @@ export const sortingMixin = Vue.extend({
254254 'aria-sort' : ariaSort
255255 }
256256 } ,
257+ // A label to be placed in an `.sr-only` element in the header cell
257258 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
259260 if ( ! this . isSortable || ( isFoot && this . noFooterSorting ) ) {
260- // No label if not a sortable table
261261 return null
262262 }
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
265266 let labelSorting = ''
266267 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
270271 } else {
271- // Not currently sorted sortable column.
272+ // Not currently sorted sortable column
272273 // 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
276277 const sortDirection = this . sortDirection || field . sortDirection
277278 if ( sortDirection === SORT_DIRECTION_ASC ) {
278- labelSorting = this . labelSortAsc
279+ labelSorting = labelSortAsc
279280 } else if ( sortDirection === SORT_DIRECTION_DESC ) {
280- labelSorting = this . labelSortDesc
281+ labelSorting = labelSortDesc
281282 }
282283 }
283284 } else if ( ! this . noSortReset ) {
284285 // Non sortable column
285- labelSorting = this . localSortBy ? this . labelSortClear : ''
286+ labelSorting = localSortBy ? this . labelSortClear : ''
286287 }
287- // Return the sr-only sort label or null if no label
288+ // Return the `. sr-only` sort label or ` null` if no label
288289 return trim ( labelSorting ) || null
289290 }
290291 }
0 commit comments