-
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.
feat(aria/get-roles-by-type): deprecate in favor of standards/get-ari…
…a-roles-by-type (#2362) * feat(aria/get-roles-by-type): deprecate in favor of standards/get-aria-roles-by-type * replace functions
- Loading branch information
Showing
6 changed files
with
42 additions
and
31 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,17 +1,16 @@ | ||
import lookupTable from './lookup-table'; | ||
import getAriaRolesByType from '../standards/get-aria-roles-by-type'; | ||
|
||
/** | ||
* Get the roles that have a certain "type" | ||
* @method getRolesByType | ||
* @memberof axe.commons.aria | ||
* @deprecated use standards/get-aria-roles-by-type | ||
* @instance | ||
* @param {String} roleType The roletype to check | ||
* @return {Array} Array of roles that match the type | ||
*/ | ||
function getRolesByType(roleType) { | ||
return Object.keys(lookupTable.role).filter(function(r) { | ||
return lookupTable.role[r].type === roleType; | ||
}); | ||
return getAriaRolesByType(roleType); | ||
} | ||
|
||
export default getRolesByType; |
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,31 @@ | ||
describe('aria.getRolesByType', function() { | ||
'use strict'; | ||
|
||
before(function() { | ||
axe._load({}); | ||
}); | ||
|
||
afterEach(function() { | ||
axe.reset(); | ||
}); | ||
|
||
it('should return array if roletype is found in the lookup table', function() { | ||
axe.configure({ | ||
standards: { | ||
ariaRoles: { | ||
dogs: { | ||
type: 'things' | ||
}, | ||
cats: { | ||
type: 'stuff' | ||
} | ||
} | ||
} | ||
}); | ||
assert.deepEqual(axe.commons.aria.getRolesByType('stuff'), ['cats']); | ||
}); | ||
|
||
it('should return empty array if role is not found in the lookup table', function() { | ||
assert.deepEqual(axe.commons.aria.getRolesByType('blahblahblah'), []); | ||
}); | ||
}); |
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