diff --git a/sources/__tests__/accessible-name.js b/sources/__tests__/accessible-name.js index 8380010e..37aee335 100644 --- a/sources/__tests__/accessible-name.js +++ b/sources/__tests__/accessible-name.js @@ -274,3 +274,87 @@ test.each([ // byTitle('Hello, Dave!') => byRole('textbox', {name: 'Hello, Dave!'}) [``, "Hello, Dave!"] ])(`test #%#`, testMarkup); + +describe("prohibited naming", () => { + test.each([ + ["caption", "
table
"], + ["code", '
named?
'], + ["deletion", '
named?
'], + ["emphasis", '
named?
'], + ["generic", '
named?
'], + ["insertion", '
named?
'], + ["paragraph", '
named?
'], + ["presentation", '
named?
'], + ["strong", '
named?
'], + ["subscript", '
named?
'], + ["superscript", "
Hello
"] + ])("role '%s' prohibites naming", (_, markup) => { + testMarkup(markup, ""); + }); + + test.each([ + [ + "caption", + ` +
+
a table
+`, + "a table" + ], + [ + "code", + "", + "html-aam" + ], + [ + "deletion", + "", + "aria 1.1 1.2" + ], + [ + "emphasis", + "", + "aria 1.2" + ], + [ + "generic", + "", + "click" + ], + [ + "insertion", + "", + "wai aria" + ], + [ + "paragraph", + "", + "I'm getting lazy" + ], + [ + "presentation", + "", + "icon" + ], + [ + "strong", + "", + "CLICK!" + ], + [ + "subscript", + "", + "A _x" + ], + [ + "superscript", + "", + "2 64" + ] + ])( + "role '%s'can be part of the accessible name of another element", + (_, markup, name) => { + testMarkup(markup, name); + } + ); +}); diff --git a/sources/accessible-name.ts b/sources/accessible-name.ts index bff6c969..9169b92a 100644 --- a/sources/accessible-name.ts +++ b/sources/accessible-name.ts @@ -21,10 +21,22 @@ function asFlatString(s: string): FlatString { } /** - * TODO + * https://w3c.github.io/aria/#namefromprohibited */ function prohibitsNaming(node: Node): boolean { - return false; + return hasAnyConcreteRoles(node, [ + "caption", + "code", + "deletion", + "emphasis", + "generic", + "insertion", + "paragraph", + "presentation", + "strong", + "subscript", + "superscript" + ]); } function isElement(node: Node | null): node is Element {