Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/injected/src/roleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ function getIdRefs(element: Element, ref: string | null): Element[] {
if (!root)
return [];
try {
const ids = ref.split(' ').filter(id => !!id);
// ID reference lists are separated by ASCII whitespace, which does not include e.g.  .
const ids = ref.split(/[ \t\n\f\r]+/).filter(id => !!id);
const result: Element[] = [];
for (const id of ids) {
// https://www.w3.org/TR/wai-aria-1.2/#mapping_additional_relations_error_processing
Expand Down
2 changes: 2 additions & 0 deletions tests/library/role-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ test('native controls labelled-by', async ({ page }) => {
<label id="for-button2">BUTTON2</label><button aria-labelledby="for-button2 button2" id="button2">MORE2</button>
<label id="for-button3" for="button3">BUTTON3</label><button aria-labelledby="for-button3 button3" id="button3">MORE3</button>
<label id="for-button4" for="button4">BUTTON4</label><button aria-labelledby="for-button4" id="button4">MORE4</button>
<label id="for\u00a0button5">BUTTON5</label><button aria-labelledby="for\u00a0button5\n\tbutton5" id="button5">MORE5</button>

<label id="for-textarea1" for="textarea1">TEXTAREA1</label><textarea aria-labelledby="for-textarea1 textarea1" id="textarea1" placeholder="MORE1">MORE2</textarea>
`);
Expand All @@ -413,6 +414,7 @@ test('native controls labelled-by', async ({ page }) => {
expect.soft(await getNameAndRole(page, '#button2')).toEqual({ role: 'button', name: 'BUTTON2 MORE2' });
expect.soft(await getNameAndRole(page, '#button3')).toEqual({ role: 'button', name: 'BUTTON3 MORE3' });
expect.soft(await getNameAndRole(page, '#button4')).toEqual({ role: 'button', name: 'BUTTON4' });
expect.soft(await getNameAndRole(page, '#button5')).toEqual({ role: 'button', name: 'BUTTON5 MORE5' });
expect.soft(await getNameAndRole(page, '#textarea1')).toEqual({ role: 'textbox', name: 'TEXTAREA1 MORE2' });
});

Expand Down