Skip to content

Commit

Permalink
fix(aria-roles): address pr comments
Browse files Browse the repository at this point in the history
- learned sometimes we intentionally spec change
- added `window` as a supported type, and `composite` which was missing from the readme
- undid my change to `isWidgetType`

Refs: #4371
  • Loading branch information
gaiety-deque committed Apr 25, 2024
1 parent fd59e8d commit 2d185f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions doc/standards-object.md
Expand Up @@ -67,9 +67,11 @@ The [`ariaRoles`](../lib/standards/aria-roles.js) object defines valid ARIA role

- `type` - string(required). [The role type](https://www.w3.org/TR/wai-aria-1.1/#roles_categorization). Valid types are:
- `abstract`
- `widget`
- `structure`
- `composite`
- `landmark`
- `structure`
- `widget`
- `window`
- `requiredContext` - array(optional). List of required parent roles.
- `requiredOwned` - array(optional). List of required owned roles.
- `requiredAttrs` - array(optional). List of required attributes.
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/widget-not-inline-matches.js
Expand Up @@ -18,8 +18,7 @@ const matchesFns = [
];

function isWidgetType(vNode) {
const roleType = getRoleType(vNode);
return roleType === 'widget' || roleType === 'composite';
return getRoleType(vNode) === 'widget';
}

function isNotAreaElement(vNode) {
Expand Down
10 changes: 6 additions & 4 deletions lib/standards/aria-roles.js
@@ -1,5 +1,5 @@
// Source: https://www.w3.org/TR/wai-aria-1.1/#roles
// Source for abstract roles: https://www.w3.org/TR/wai-aria/#abstract_roles and https://www.w3.org/WAI/ARIA/1.2/class-diagram/rdf_model.svg
// Source for abstract roles (types): https://www.w3.org/TR/wai-aria/#abstract_roles

/* easiest way to see allowed roles is to filter out the global ones
from the list of inherited states and properties. The dpub spec
Expand Down Expand Up @@ -32,7 +32,7 @@ const ariaRoles = {
},
application: {
// Note: spec difference
type: 'structure',
type: 'landmark',
// Note: aria-expanded is not in the 1.1 spec but is
// consistently supported in ATs and was added in 1.2
allowedAttrs: ['aria-activedescendant', 'aria-expanded'],
Expand Down Expand Up @@ -120,7 +120,8 @@ const ariaRoles = {
nameFromContent: true
},
combobox: {
type: 'composite',
// Note: spec difference
type: 'widget',
requiredAttrs: ['aria-expanded', 'aria-controls'],
allowedAttrs: [
'aria-owns',
Expand Down Expand Up @@ -302,7 +303,8 @@ const ariaRoles = {
superclassRole: ['section']
},
listbox: {
type: 'composite',
// Note: spec difference
type: 'widget',
requiredOwned: ['group', 'option'],
allowedAttrs: [
'aria-multiselectable',
Expand Down

0 comments on commit 2d185f6

Please sign in to comment.