-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(aria-level): New check for aria-level > 6 as needs review (#3061)
* new aria-level check works * add test * fix integration tests * fix tests
- Loading branch information
Showing
8 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Check that an element does not have aria-level values exceeding 6 | ||
* VO and NVDA allow any positive value | ||
* JAWS and TalkBack will give the default value if level > 6 | ||
* See browser/screenreader support research https://codepen.io/straker/pen/jOBjNNe | ||
* @memberof checks | ||
* @return {Boolean} Undefined if the element uses aria-level > 6. True otherwise. | ||
*/ | ||
function ariaLevelEvaluate(node, options, virtualNode) { | ||
const ariaHeadingLevel = virtualNode.attr('aria-level'); | ||
const ariaLevel = parseInt(ariaHeadingLevel, 10); | ||
if (ariaLevel > 6) { | ||
return undefined; | ||
} | ||
return true; | ||
} | ||
|
||
export default ariaLevelEvaluate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"id": "aria-level", | ||
"evaluate": "aria-level-evaluate", | ||
"metadata": { | ||
"impact": "serious", | ||
"messages": { | ||
"pass": "aria-level values are valid", | ||
"incomplete": "aria-level values greater than 6 are not supported in all screenreader and browser combinations" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
describe('aria-prohibited-attr', function() { | ||
'use strict'; | ||
|
||
var checkContext = axe.testUtils.MockCheckContext(); | ||
var checkSetup = axe.testUtils.checkSetup; | ||
var checkEvaluate = axe.testUtils.getCheckEvaluate('aria-level'); | ||
|
||
afterEach(function() { | ||
checkContext.reset(); | ||
}); | ||
|
||
it('should return true if aria-level is less than 6', function() { | ||
var params = checkSetup('<div id="target" aria-level="2">Contents</div>'); | ||
assert.isTrue(checkEvaluate.apply(checkContext, params)); | ||
}); | ||
|
||
it('should return true if aria-level is 6', function() { | ||
var params = checkSetup('<div id="target" aria-level="6">Contents</div>'); | ||
assert.isTrue(checkEvaluate.apply(checkContext, params)); | ||
}); | ||
|
||
it('should return true if aria-level is negative', function() { | ||
var params = checkSetup('<div id="target" aria-level="-2">Contents</div>'); | ||
assert.isTrue(checkEvaluate.apply(checkContext, params)); | ||
}); | ||
|
||
it('should return true if there is no aria-level', function() { | ||
var params = checkSetup('<div id="target">Contents</div>'); | ||
assert.isTrue(checkEvaluate.apply(checkContext, params)); | ||
}); | ||
|
||
it('should return undefined if aria-level is greater than 6', function() { | ||
var params = checkSetup('<div id="target" aria-level="8">Contents</div>'); | ||
assert.isUndefined(checkEvaluate.apply(checkContext, params)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters