This commit is contained in:
parent
120cdf664b
commit
b3aaee0248
|
|
@ -383,7 +383,11 @@ export function getAriaLabelledByElements(element: Element): Element[] | null {
|
||||||
const ref = element.getAttribute('aria-labelledby');
|
const ref = element.getAttribute('aria-labelledby');
|
||||||
if (ref === null)
|
if (ref === null)
|
||||||
return null;
|
return null;
|
||||||
return getIdRefs(element, ref);
|
const refs = getIdRefs(element, ref);
|
||||||
|
// step 2b:
|
||||||
|
// "if the current node has an aria-labelledby attribute that contains at least one valid IDREF"
|
||||||
|
// Therefore, if none of the refs match an element, we consider aria-labelledby to be missing.
|
||||||
|
return refs.length ? refs : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function allowsNameFromContent(role: string, targetDescendant: boolean) {
|
function allowsNameFromContent(role: string, targetDescendant: boolean) {
|
||||||
|
|
|
||||||
|
|
@ -495,6 +495,16 @@ test('should not include hidden pseudo into accessible name', async ({ page }) =
|
||||||
expect.soft(await getNameAndRole(page, 'a')).toEqual({ role: 'link', name: 'hello hello' });
|
expect.soft(await getNameAndRole(page, 'a')).toEqual({ role: 'link', name: 'hello hello' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should ignore invalid aria-labelledby', async ({ page }) => {
|
||||||
|
await page.setContent(`
|
||||||
|
<label>
|
||||||
|
<span>Text here</span>
|
||||||
|
<input type=text aria-labelledby="does-not-exist">
|
||||||
|
</label>
|
||||||
|
`);
|
||||||
|
expect.soft(await getNameAndRole(page, 'input')).toEqual({ role: 'textbox', name: 'Text here' });
|
||||||
|
});
|
||||||
|
|
||||||
function toArray(x: any): any[] {
|
function toArray(x: any): any[] {
|
||||||
return Array.isArray(x) ? x : [x];
|
return Array.isArray(x) ? x : [x];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue