From 44269ec6695645417dda03b26fcb04abebc15f5f Mon Sep 17 00:00:00 2001 From: Steven Lambert <2433219+straker@users.noreply.github.com> Date: Fri, 22 May 2020 10:15:48 -0600 Subject: [PATCH] feat(scope-value): add options for valid scope values (#2245) --- lib/checks/tables/scope-value-evaluate.js | 4 +--- lib/checks/tables/scope-value.json | 3 +++ test/checks/tables/scope-value.js | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/checks/tables/scope-value-evaluate.js b/lib/checks/tables/scope-value-evaluate.js index f870009189..0aa572029a 100644 --- a/lib/checks/tables/scope-value-evaluate.js +++ b/lib/checks/tables/scope-value-evaluate.js @@ -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; diff --git a/lib/checks/tables/scope-value.json b/lib/checks/tables/scope-value.json index 9d182e42d3..55c1382243 100644 --- a/lib/checks/tables/scope-value.json +++ b/lib/checks/tables/scope-value.json @@ -1,6 +1,9 @@ { "id": "scope-value", "evaluate": "scope-value-evaluate", + "options": { + "values": ["row", "col", "rowgroup", "colgroup"] + }, "metadata": { "impact": "critical", "messages": { diff --git a/test/checks/tables/scope-value.js b/test/checks/tables/scope-value.js index 9964266f55..1633a44d6d 100644 --- a/test/checks/tables/scope-value.js +++ b/test/checks/tables/scope-value.js @@ -28,4 +28,16 @@ describe('scope-value', function() { assert.isFalse(axe.testUtils.getCheckEvaluate('scope-value')(node)); }); + + it('should support options.values', function() { + fixture.innerHTML = + '