You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: aria-labelledby and aria-describedby ignore IDs separated by a newline or a tab #43359
import{test,expect}from'@playwright/test';test('id reference lists separated by a newline or a tab',async({ page })=>{awaitpage.setContent(` <span id="first">Hello</span><span id="last">World</span> <span id="hint">Some hint</span><span id="err">Required</span> <button aria-labelledby="first\n last">x</button> <input aria-label="Email" aria-describedby="hint\terr"> `);awaitexpect.soft(page.getByRole('button')).toHaveAccessibleName('Hello World');awaitexpect.soft(page.getByRole('textbox')).toHaveAccessibleDescription('Some hint Required');});
npx playwright test
Expected behavior
Both assertions pass. ID reference lists are separated by ASCII whitespace, so a newline or a tab between IDs works the same as a space. Chromium's own accessibility tree (Accessibility.getFullAXTree) reports the name Hello World for the button and the description Some hint Required for the textbox.
ariaSnapshot() shows - button "World": x, and getByRole('button', { name: 'Hello World' }) matches nothing. This happens with formatted HTML where a long aria-labelledby list is wrapped onto several lines.
Additional context
getIdRefs in packages/injected/src/roleUtils.ts splits the attribute with ref.split(' '). A token like first\n then matches no element and is dropped. The same helper is used for aria-labelledby, aria-describedby, aria-errormessage and aria-owns. ariaSnapshot.ts already splits aria-owns with /\s+/.
I'd like to send a PR that splits on whitespace instead, with an extra case in the native controls labelled-by test in tests/library/role-utils.spec.ts.
Activity