Skip to content

Commit 6919cc5

Browse files
authored
fix(table): Remove redundant ARIA roles from b-table (bootstrap-vue#662)
* 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
1 parent 22d278f commit 6919cc5

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

__tests__/components/table.spec.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -163,36 +163,6 @@ describe('table', async() => {
163163
}
164164
})
165165

166-
it('all example tables should have ARIA role="grid"', async() => {
167-
const { app: { $refs, $el } } = window
168-
169-
const tables = [ 'table_basic', 'table_paginated', 'table_inverse' ]
170-
171-
tables.forEach(table => {
172-
expect($refs[table].$el.getAttribute('role')).toBe('grid')
173-
})
174-
})
175-
176-
it('each data row should have ARIA role "row"', async() => {
177-
const { app: { $refs, $el } } = window
178-
const app = window.app
179-
180-
const tables = [ 'table_basic', 'table_paginated', 'table_inverse' ]
181-
182-
tables.forEach(table => {
183-
const vm = $refs[table]
184-
const tbody = [...vm.$el.children].find(el => el && el.tagName === 'TBODY')
185-
expect(tbody).toBeDefined()
186-
if (tbody) {
187-
const trs = [...tbody.children]
188-
expect(trs.length).toBe(vm.perPage || app.items.length)
189-
trs.forEach( tr => {
190-
expect(tr.getAttribute('role')).toBe('row')
191-
})
192-
}
193-
})
194-
})
195-
196166
it('all example tables should have attribute aria-busy="false" when busy is false', async() => {
197167
const { app: { $refs, $el } } = window
198168

lib/components/table.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<template>
22
<table :id="id || null"
3-
role="grid"
43
:aria-busy="busy ? 'true' : 'false'"
54
:class="tableClass"
65
>
76
<thead :class="headClass">
8-
<tr role="row">
7+
<tr>
98
<th v-for="(field,key) in fields"
109
@click.stop.prevent="headClicked($event,field,key)"
1110
@keydown.enter.stop.prevent="headClicked($event,field,key)"
@@ -24,7 +23,7 @@
2423
</tr>
2524
</thead>
2625
<tfoot v-if="footClone" :class="footClass">
27-
<tr role="row">
26+
<tr>
2827
<th v-for="(field,key) in fields"
2928
@click.stop.prevent="headClicked($event,field,key)"
3029
@keydown.enter.stop.prevent="headClicked($event,field,key)"
@@ -47,7 +46,6 @@
4746
</tfoot>
4847
<tbody>
4948
<tr v-for="(item,index) in _items"
50-
role="row"
5149
:key="index"
5250
:class="rowClass(item)"
5351
@click="rowClicked($event,item,index)"
@@ -57,7 +55,7 @@
5755
<slot :name="key" :value="item[key]" :item="item" :index="index">{{item[key]}}</slot>
5856
</td>
5957
</tr>
60-
<tr v-if="showEmpty && (!_items || _items.length === 0)" role="row">
58+
<tr v-if="showEmpty && (!_items || _items.length === 0)">
6159
<td :colspan="Object.keys(fields).length">
6260
<div v-if="filter" role="alert" aria-live="polite">
6361
<slot name="emptyfiltered">

0 commit comments

Comments
 (0)