From 5aae223dc59ade33d458a080ce5626ed616daf65 Mon Sep 17 00:00:00 2001 From: alonidiom <120664064+alonidiom@users.noreply.github.com> Date: Thu, 25 May 2023 10:12:16 +0300 Subject: [PATCH 1/2] feat: support aria-description as descriptor --- sources/__tests__/accessible-description.js | 8 ++++++++ sources/accessible-description.ts | 10 +++++++++- sources/getRole.ts | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sources/__tests__/accessible-description.js b/sources/__tests__/accessible-description.js index 4f85ddf9..ba23ea1b 100644 --- a/sources/__tests__/accessible-description.js +++ b/sources/__tests__/accessible-description.js @@ -59,6 +59,14 @@ describe("wpt copies", () => { `United States`, "San Francisco", ], + [ + ``, + "Paid feature", + ], + [ + `testfoo`, + "foo", + ], ])(`#%#`, (markup, expectedAccessibleDescription) => { expect(markup).toRenderIntoDocumentAccessibleDescription( expectedAccessibleDescription diff --git a/sources/accessible-description.ts b/sources/accessible-description.ts index 0404d4e0..3445ad8e 100644 --- a/sources/accessible-description.ts +++ b/sources/accessible-description.ts @@ -24,7 +24,15 @@ export function computeAccessibleDescription( // TODO: Technically we need to make sure that node wasn't used for the accessible name // This causes `description_1.0_combobox-focusable-manual` to fail - // + + // https://w3c.github.io/aria/#aria-description + // mentions that aria-description should only be calculated if aria-describedby didn't provide + // a description + if (description === "") { + const ariaDescription = root.getAttribute("aria-description"); + description = ariaDescription === null ? "" : ariaDescription; + } + // https://www.w3.org/TR/html-aam-1.0/#accessible-name-and-description-computation // says for so many elements to use the `title` that we assume all elements are considered if (description === "") { diff --git a/sources/getRole.ts b/sources/getRole.ts index 47f9b8b1..f7de0003 100644 --- a/sources/getRole.ts +++ b/sources/getRole.ts @@ -90,6 +90,7 @@ function hasGlobalAriaAttributes(element: Element, role: string): boolean { "aria-busy", "aria-controls", "aria-current", + "aria-description", "aria-describedby", "aria-details", // "disabled", From dbf7b305733f6ac8103bdff05a67ac238c331571 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Thu, 25 May 2023 15:09:45 +0200 Subject: [PATCH 2/2] Create two-eagles-peel.md --- .changeset/two-eagles-peel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/two-eagles-peel.md diff --git a/.changeset/two-eagles-peel.md b/.changeset/two-eagles-peel.md new file mode 100644 index 00000000..791b5e6a --- /dev/null +++ b/.changeset/two-eagles-peel.md @@ -0,0 +1,5 @@ +--- +"dom-accessibility-api": patch +--- + +Support `aria-description` as descriptor