-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(aria-required-children): only match for roles that require childr…
…en (#2703) * fix(aria-required-children): only match for roles that require children * fix * fix tests
- Loading branch information
Showing
6 changed files
with
60 additions
and
37 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,8 @@ | ||
import { requiredOwned, getExplicitRole } from '../commons/aria'; | ||
|
||
function ariaRequiredChildrenMatches(node, virtualNode) { | ||
const role = getExplicitRole(virtualNode, { dpub: true }); | ||
return !!requiredOwned(role); | ||
} | ||
|
||
export default ariaRequiredChildrenMatches; |
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
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,27 @@ | ||
describe('aria-required-children-matches', function() { | ||
'use strict'; | ||
|
||
var fixture = document.getElementById('fixture'); | ||
var queryFixture = axe.testUtils.queryFixture; | ||
var rule; | ||
|
||
beforeEach(function() { | ||
rule = axe._audit.rules.find(function(rule) { | ||
return rule.id === 'aria-required-children'; | ||
}); | ||
}); | ||
|
||
afterEach(function() { | ||
fixture.innerHTML = ''; | ||
}); | ||
|
||
it('should return true for a role that requires children', function() { | ||
var vNode = queryFixture('<div id="target" role="list"></div>'); | ||
assert.isTrue(rule.matches(null, vNode)); | ||
}); | ||
|
||
it('should return false for a role that does not require children', function() { | ||
var vNode = queryFixture('<div id="target" role="alert"></div>'); | ||
assert.isFalse(rule.matches(null, vNode)); | ||
}); | ||
}); |