Skip to content

Commit

Permalink
fix(table): Remove redundant ARIA roles from b-table (#662)
Browse files Browse the repository at this point in the history
* fix(table): Remove redundant ARIA roles from table
Role `grid` and `row` are implied automatically by current table semantic markup, and not necessary.
Based on chrome Accessibility Plugin Audit  of renderd `<b-table>`
* fix(texts): Remove tests for b-table roles grid and row
  • Loading branch information
tmorehouse authored Jul 7, 2017
1 parent 22d278f commit 6919cc5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
30 changes: 0 additions & 30 deletions __tests__/components/table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,36 +163,6 @@ describe('table', async() => {
}
})

it('all example tables should have ARIA role="grid"', async() => {
const { app: { $refs, $el } } = window

const tables = [ 'table_basic', 'table_paginated', 'table_inverse' ]

tables.forEach(table => {
expect($refs[table].$el.getAttribute('role')).toBe('grid')
})
})

it('each data row should have ARIA role "row"', async() => {
const { app: { $refs, $el } } = window
const app = window.app

const tables = [ 'table_basic', 'table_paginated', 'table_inverse' ]

tables.forEach(table => {
const vm = $refs[table]
const tbody = [...vm.$el.children].find(el => el && el.tagName === 'TBODY')
expect(tbody).toBeDefined()
if (tbody) {
const trs = [...tbody.children]
expect(trs.length).toBe(vm.perPage || app.items.length)
trs.forEach( tr => {
expect(tr.getAttribute('role')).toBe('row')
})
}
})
})

it('all example tables should have attribute aria-busy="false" when busy is false', async() => {
const { app: { $refs, $el } } = window

Expand Down
8 changes: 3 additions & 5 deletions lib/components/table.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<template>
<table :id="id || null"
role="grid"
:aria-busy="busy ? 'true' : 'false'"
:class="tableClass"
>
<thead :class="headClass">
<tr role="row">
<tr>
<th v-for="(field,key) in fields"
@click.stop.prevent="headClicked($event,field,key)"
@keydown.enter.stop.prevent="headClicked($event,field,key)"
Expand All @@ -24,7 +23,7 @@
</tr>
</thead>
<tfoot v-if="footClone" :class="footClass">
<tr role="row">
<tr>
<th v-for="(field,key) in fields"
@click.stop.prevent="headClicked($event,field,key)"
@keydown.enter.stop.prevent="headClicked($event,field,key)"
Expand All @@ -47,7 +46,6 @@
</tfoot>
<tbody>
<tr v-for="(item,index) in _items"
role="row"
:key="index"
:class="rowClass(item)"
@click="rowClicked($event,item,index)"
Expand All @@ -57,7 +55,7 @@
<slot :name="key" :value="item[key]" :item="item" :index="index">{{item[key]}}</slot>
</td>
</tr>
<tr v-if="showEmpty && (!_items || _items.length === 0)" role="row">
<tr v-if="showEmpty && (!_items || _items.length === 0)">
<td :colspan="Object.keys(fields).length">
<div v-if="filter" role="alert" aria-live="polite">
<slot name="emptyfiltered">
Expand Down

0 comments on commit 6919cc5

Please sign in to comment.