Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aria-roles): correct abstract roles (types) for aria-roles #4421

Merged
merged 14 commits into from May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rules/widget-not-inline-matches.js
Expand Up @@ -18,7 +18,8 @@ const matchesFns = [
];

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo this change since we'll leave listbox and combobox as widgets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undid this change 2d185f6

}

function isNotAreaElement(vNode) {
Expand Down
21 changes: 11 additions & 10 deletions lib/standards/aria-roles.js
@@ -1,4 +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
gaiety-deque marked this conversation as resolved.
Show resolved Hide resolved

/* 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 All @@ -17,21 +18,21 @@
*/
const ariaRoles = {
alert: {
type: 'widget',
type: 'structure',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a problem for focus-order-semantics. With this change, the following is going to start failing. I don't think we should want that.

<div role="alert" tabindex="0"> Hello world </div>

This is what we talked about on Thursday. We'll need some way to exempt these roles that are no longer considered as widgets in the focus-order-semantics rule. I think the best way to do that is just to add them to the VALID_ROLES_FOR_SCROLLABLE_REGIONS object in valid-scrollable-semantics-evaluate.

// Spec difference: Aria-expanded removed in 1.2
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
},
alertdialog: {
type: 'widget',
type: 'window',
straker marked this conversation as resolved.
Show resolved Hide resolved
// Spec difference: Aria-expanded removed in 1.2
allowedAttrs: ['aria-expanded', 'aria-modal'],
superclassRole: ['alert', 'dialog'],
accessibleNameRequired: true
},
application: {
// Note: spec difference
type: 'landmark',
type: 'structure',
gaiety-deque marked this conversation as resolved.
Show resolved Hide resolved
// 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 @@ -119,7 +120,7 @@ const ariaRoles = {
nameFromContent: true
},
combobox: {
type: 'widget',
type: 'composite',
gaiety-deque marked this conversation as resolved.
Show resolved Hide resolved
requiredAttrs: ['aria-expanded', 'aria-controls'],
allowedAttrs: [
'aria-owns',
Expand Down Expand Up @@ -169,7 +170,7 @@ const ariaRoles = {
prohibitedAttrs: ['aria-label', 'aria-labelledby']
},
dialog: {
type: 'widget',
type: 'window',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably structure again as not a landmark

Suggested change
type: 'window',
type: 'structure',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we said window is fine for alertdialog I assume it's fine here as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Ava. Since this is window in the spec, lets have it consistent.

// Spec difference: Aria-expanded removed in 1.2
allowedAttrs: ['aria-expanded', 'aria-modal'],
superclassRole: ['window'],
Expand Down Expand Up @@ -301,7 +302,7 @@ const ariaRoles = {
superclassRole: ['section']
},
listbox: {
type: 'widget',
type: 'composite',
gaiety-deque marked this conversation as resolved.
Show resolved Hide resolved
requiredOwned: ['group', 'option'],
allowedAttrs: [
'aria-multiselectable',
Expand All @@ -328,7 +329,7 @@ const ariaRoles = {
nameFromContent: true
},
log: {
type: 'widget',
type: 'structure',
// Spec difference: Aria-expanded removed in 1.2
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
Expand All @@ -340,7 +341,7 @@ const ariaRoles = {
superclassRole: ['landmark']
},
marquee: {
type: 'widget',
type: 'structure',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you're adding roles to valid-scrollable-semantics, I think you can leave this one out. role=marquee doesn't seem like it should be focusable.

// Spec difference: Aria-expanded removed in 1.2
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
Expand Down Expand Up @@ -696,7 +697,7 @@ const ariaRoles = {
accessibleNameRequired: true
},
status: {
type: 'widget',
type: 'structure',
// Spec difference: Aria-expanded removed in 1.2
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
Expand Down Expand Up @@ -816,7 +817,7 @@ const ariaRoles = {
superclassRole: ['section']
},
timer: {
type: 'widget',
type: 'structure',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you're adding roles to valid-scrollable-semantics, I think you can leave this one out. role=timer doesn't seem like it should be focusable.

// Spec difference: Aria-expanded removed in 1.2
allowedAttrs: ['aria-expanded'],
superclassRole: ['status']
Expand Down
15 changes: 8 additions & 7 deletions test/commons/table/is-data-table.js
Expand Up @@ -32,6 +32,14 @@ describe('table.isDataTable', function () {
assert.isFalse(axe.commons.table.isDataTable(node));
});

it('should be false if the table has role=application, which is an astract role of structure', function () {
fixture.innerHTML = '<table role="application"></table>';

var node = fixture.querySelector('table');
axe.testUtils.flatTreeSetup(fixture.firstChild);
assert.isFalse(axe.commons.table.isDataTable(node));
});

it('should be true if the table is inside an editable area', function () {
fixture.innerHTML =
'<div contenteditable="true">' +
Expand Down Expand Up @@ -71,13 +79,6 @@ describe('table.isDataTable', function () {
});

describe('should be true if the table has a landmark role', function () {
it('application', function () {
fixture.innerHTML = '<table role="application"></table>';

var node = fixture.querySelector('table');
axe.testUtils.flatTreeSetup(fixture.firstChild);
assert.isTrue(axe.commons.table.isDataTable(node));
});
it('banner', function () {
fixture.innerHTML = '<table role="banner"></table>';

Expand Down