-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SIA-R116:
<summary>
element has non-empty accessible name (#1728)
* Add SIA-R116: summary element has non-empty accessible name * Add SIA-R116: <summary> element has non-empty accessible name * Fix implicit role of <details> * Add changeset * WiP on tests * Extract isSummaryForItsParentDetail augment * Typo * Fix handling of summary elements * Refactor * Improve documentation * Add test cases * Fix summary name computation * Clean up
- Loading branch information
Showing
15 changed files
with
388 additions
and
30 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@siteimprove/alfa-aria": patch | ||
--- | ||
|
||
**Fixed:** `<summary>` elements that are not summary for their parent details are now correctly treated as `generic` role. |
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,5 @@ | ||
--- | ||
"@siteimprove/alfa-dom": minor | ||
--- | ||
|
||
**Added:** An `Element<"summary">#isSummaryForItsParentDetails` predicate is now available. |
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,5 @@ | ||
--- | ||
"@siteimprove/alfa-rules": minor | ||
--- | ||
|
||
**Added:** SIA-R116: "`<summary>` element has non-empty accessible name" is now available. |
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,5 @@ | ||
--- | ||
"@siteimprove/alfa-aria": patch | ||
--- | ||
|
||
**Fixed:** `<details>` elements now correctly have an implicit role of `group`. |
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,5 @@ | ||
--- | ||
"@siteimprove/alfa-aria": patch | ||
--- | ||
|
||
**Fixed:** `<summary>` elements that are summary for their parent details now correctly have their name computed from content. |
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
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
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,70 @@ | ||
import { Diagnostic, Rule } from "@siteimprove/alfa-act"; | ||
import { DOM, Role } from "@siteimprove/alfa-aria"; | ||
import { Element, Namespace, Node, Query } from "@siteimprove/alfa-dom"; | ||
import { Refinement } from "@siteimprove/alfa-refinement"; | ||
import { Err, Ok } from "@siteimprove/alfa-result"; | ||
import { Criterion } from "@siteimprove/alfa-wcag"; | ||
import type { Page } from "@siteimprove/alfa-web"; | ||
|
||
import { expectation } from "../common/act/expectation.js"; | ||
|
||
import { Scope, Stability } from "../tags/index.js"; | ||
|
||
const { | ||
hasExplicitRole, | ||
hasNonEmptyAccessibleName, | ||
isIncludedInTheAccessibilityTree, | ||
} = DOM; | ||
const { hasName, hasNamespace } = Element; | ||
const { and, not } = Refinement; | ||
const { getElementDescendants } = Query; | ||
|
||
export default Rule.Atomic.of<Page, Element<"summary">>({ | ||
uri: "https://alfa.siteimprove.com/rules/sia-r116", | ||
requirements: [Criterion.of("4.1.2")], | ||
tags: [Scope.Component, Stability.Stable], | ||
evaluate({ device, document }) { | ||
return { | ||
applicability() { | ||
return getElementDescendants(document, Node.fullTree) | ||
.filter(and(hasNamespace(Namespace.HTML), hasName("summary"))) | ||
.filter( | ||
and( | ||
isIncludedInTheAccessibilityTree(device), | ||
(summary) => summary.isSummaryForItsParentDetails(), | ||
// If the explicit role is none/presentation but the element is | ||
// nonetheless included in the accessibility tree, then the | ||
// conflict triggered, and we want to keep it as target. | ||
not(hasExplicitRole(not(Role.hasName("none", "presentation")))), | ||
), | ||
); | ||
}, | ||
|
||
expectations(target) { | ||
return { | ||
1: expectation( | ||
// This does not explicitly exclude the ::marker pseudo-element from | ||
// the name. Since we currently do not handle pseudo-elements, this | ||
// is effectively the wanted outcome. | ||
hasNonEmptyAccessibleName(device)(target), | ||
() => Outcomes.HasAccessibleName, | ||
() => Outcomes.HasNoAccessibleName, | ||
), | ||
}; | ||
}, | ||
}; | ||
}, | ||
}); | ||
|
||
/** | ||
* @public | ||
*/ | ||
export namespace Outcomes { | ||
export const HasAccessibleName = Ok.of( | ||
Diagnostic.of(`The \`<summary>\` element has an accessible name`), | ||
); | ||
|
||
export const HasNoAccessibleName = Err.of( | ||
Diagnostic.of(`The \`<summary>\` element does not have an accessible name`), | ||
); | ||
} |
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.