-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: better unsupported attribute support for aria-roledescription (#…
…1382) Expand the `unsupported` property of an attribute by allowing certain elements to use the attribute. Closes: #1216 ## Reviewer checks **Required fields, to be filled out by PR reviewer(s)** - [x] Follows the commit message policy, appropriate for next version - [x] Has documentation updated, a DU ticket, or requires no documentation change - [x] Includes new tests, or was unnecessary - [x] Code is reviewed for security by: @WilcoFiers
- Loading branch information
1 parent
98bf49b
commit 93f721e
Showing
11 changed files
with
313 additions
and
105 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
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 |
---|---|---|
@@ -1,16 +1,39 @@ | ||
let unsupported = Array.from(node.attributes) | ||
.filter(candidate => { | ||
// filter out unsupported attributes | ||
return axe.commons.aria.validateAttr(candidate.name, { | ||
flagUnsupported: true | ||
const nodeName = node.nodeName.toUpperCase(); | ||
const lookupTable = axe.commons.aria.lookupTable; | ||
const role = axe.commons.aria.getRole(node); | ||
|
||
const unsupportedAttrs = Array.from(node.attributes) | ||
.filter(({ name }) => { | ||
const attribute = lookupTable.attributes[name]; | ||
|
||
if (!axe.commons.aria.validateAttr(name)) { | ||
return false; | ||
} | ||
|
||
const { unsupported } = attribute; | ||
|
||
if (typeof unsupported !== 'object') { | ||
return !!unsupported; | ||
} | ||
|
||
// validate attributes and conditions (if any) from allowedElement to given node | ||
const isException = axe.commons.matches(node, unsupported.exceptions); | ||
|
||
if (!Object.keys(lookupTable.evaluateRoleForElement).includes(nodeName)) { | ||
return !isException; | ||
} | ||
|
||
// evaluate a given aria-role, execute the same | ||
return !lookupTable.evaluateRoleForElement[nodeName]({ | ||
node, | ||
role, | ||
out: isException | ||
}); | ||
}) | ||
.map(candidate => { | ||
return candidate.name.toString(); | ||
}); | ||
.map(candidate => candidate.name.toString()); | ||
|
||
if (unsupported.length) { | ||
this.data(unsupported); | ||
if (unsupportedAttrs.length) { | ||
this.data(unsupportedAttrs); | ||
return true; | ||
} | ||
return false; |
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
Oops, something went wrong.