Skip to content

Commit

Permalink
feat(scope-value): add options for valid scope values (#2245)
Browse files Browse the repository at this point in the history
  • Loading branch information
straker authored May 22, 2020
1 parent 2eadb15 commit 44269ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/checks/tables/scope-value-evaluate.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
function scopeValueEvaluate(node, options) {
options = options || {};
var value = node.getAttribute('scope').toLowerCase();
var validVals = ['row', 'col', 'rowgroup', 'colgroup'] || options.values;

return validVals.indexOf(value) !== -1;
return options.values.indexOf(value) !== -1;
}

export default scopeValueEvaluate;
3 changes: 3 additions & 0 deletions lib/checks/tables/scope-value.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"id": "scope-value",
"evaluate": "scope-value-evaluate",
"options": {
"values": ["row", "col", "rowgroup", "colgroup"]
},
"metadata": {
"impact": "critical",
"messages": {
Expand Down
12 changes: 12 additions & 0 deletions test/checks/tables/scope-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ describe('scope-value', function() {

assert.isFalse(axe.testUtils.getCheckEvaluate('scope-value')(node));
});

it('should support options.values', function() {
fixture.innerHTML =
'<table><tr><td scope="hahahahanothx"></td></tr></table>';
var node = fixture.querySelector('td');

assert.isTrue(
axe.testUtils.getCheckEvaluate('scope-value')(node, {
values: ['hahahahanothx']
})
);
});
});

0 comments on commit 44269ec

Please sign in to comment.