diff --git a/packages/injected/src/roleUtils.ts b/packages/injected/src/roleUtils.ts index 649525f0499d6..e8de076f2ca4b 100644 --- a/packages/injected/src/roleUtils.ts +++ b/packages/injected/src/roleUtils.ts @@ -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 diff --git a/tests/library/role-utils.spec.ts b/tests/library/role-utils.spec.ts index 2b23cd497fbfa..90899bc97776a 100644 --- a/tests/library/role-utils.spec.ts +++ b/tests/library/role-utils.spec.ts @@ -399,6 +399,7 @@ test('native controls labelled-by', async ({ page }) => { + `); @@ -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' }); });