-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dont flag invalid roles in unsupportedrole (#1328)
fix: don't flag invalid roles in unsupportedrole
- Loading branch information
1 parent
2660efc
commit 2dfcbaa
Showing
4 changed files
with
58 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
return !axe.commons.aria.isValidRole(node.getAttribute('role'), { | ||
flagUnsupported: true | ||
}); | ||
return axe.commons.aria.isUnsupportedRole(axe.commons.aria.getRole(node)); |
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,14 @@ | ||
/* global aria, axe */ | ||
|
||
/** | ||
* Check if a given role is unsupported | ||
* @method isUnsupportedRole | ||
* @memberof axe.commons.aria | ||
* @instance | ||
* @param {String} role The role to check | ||
* @return {Boolean} | ||
*/ | ||
aria.isUnsupportedRole = function(role) { | ||
const roleDefinition = aria.lookupTable.role[role]; | ||
return roleDefinition ? roleDefinition.unsupported : 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
describe('aria.isUnsupportedRole', function() { | ||
'use strict'; | ||
|
||
it('should return true if the role is unsupported', function() { | ||
var orig = axe.commons.aria.lookupTable.role; | ||
axe.commons.aria.lookupTable.role = { | ||
cats: { | ||
unsupported: true | ||
} | ||
}; | ||
assert.isTrue(axe.commons.aria.isUnsupportedRole('cats')); | ||
axe.commons.aria.lookupTable.role = orig; | ||
}); | ||
|
||
it('should return false if the role is supported', function() { | ||
var orig = axe.commons.aria.lookupTable.role; | ||
axe.commons.aria.lookupTable.role = { | ||
cats: { | ||
unsupported: false | ||
} | ||
}; | ||
assert.isFalse(axe.commons.aria.isUnsupportedRole('cats')); | ||
axe.commons.aria.lookupTable.role = orig; | ||
}); | ||
|
||
it('should return false if the role is invalid', function() { | ||
var orig = axe.commons.aria.lookupTable.role; | ||
axe.commons.aria.lookupTable.role = {}; | ||
assert.isFalse(axe.commons.aria.isUnsupportedRole('cats')); | ||
axe.commons.aria.lookupTable.role = orig; | ||
}); | ||
}); |