Describe the bug
When label is unset (default ''), Svg.svelte always sets:
aria-label={label}
role={label ? 'img' : 'presentation'}
That produces role="presentation" and aria-label="". An empty aria-label is still a global ARIA attribute, so axe-core rule presentation-role-conflict fails on every unlabeled icon.
Downstream report: josdejong/svelte-jsoneditor#584 (toolbar icons via svelte-awesome).
This also shows up in the HTML from #965:
aria-label="" role="presentation"
Expected behaviour
When label is empty:
- omit
aria-label entirely (do not set it to "")
- keep
role="presentation"
When label is set: role="img" + non-empty aria-label is fine.
Suggested fix
Only set naming attributes when label is non-empty, e.g.:
role={label ? 'img' : 'presentation'}
{...(label ? { 'aria-label': label } : {})}
Do not pair role="presentation" with aria-hidden="true" by default — aria-hidden is also a global ARIA attribute and trips the same axe rule. Consumers who want aria-hidden can still pass it via restProps; the important part is not emitting an empty aria-label.
Reproduction
<script>
import Icon from 'svelte-awesome'
import { faSearch } from '@fortawesome/free-solid-svg-icons'
</script>
<Icon data={faSearch} />
Inspect the SVG: role="presentation" + aria-label="". Run axe with presentation-role-conflict enabled.
Environment
svelte-awesome 3.3.5
- axe-core (
presentation-role-conflict)
fount Playwright hard-fails on axe hits. Until a fixed svelte-awesome release is consumed by svelte-jsoneditor / vanilla-jsoneditor:
- Bump / pick up the fixed
svelte-awesome in svelte-jsoneditor
- Release a
vanilla-jsoneditor that includes it
- In fount: bump the CDN pin in
src/public/pages/scripts/components/jsonEditor.mjs and remove the temporary aria-ignore for issue 584
Describe the bug
When
labelis unset (default''),Svg.sveltealways sets:aria-label={label} role={label ? 'img' : 'presentation'}That produces
role="presentation"andaria-label="". An emptyaria-labelis still a global ARIA attribute, so axe-core rulepresentation-role-conflictfails on every unlabeled icon.Downstream report: josdejong/svelte-jsoneditor#584 (toolbar icons via
svelte-awesome).This also shows up in the HTML from #965:
Expected behaviour
When
labelis empty:aria-labelentirely (do not set it to"")role="presentation"When
labelis set:role="img"+ non-emptyaria-labelis fine.Suggested fix
Only set naming attributes when
labelis non-empty, e.g.:role={label ? 'img' : 'presentation'} {...(label ? { 'aria-label': label } : {})}Do not pair
role="presentation"witharia-hidden="true"by default —aria-hiddenis also a global ARIA attribute and trips the same axe rule. Consumers who wantaria-hiddencan still pass it via restProps; the important part is not emitting an emptyaria-label.Reproduction
Inspect the SVG:
role="presentation"+aria-label="". Run axe withpresentation-role-conflictenabled.Environment
svelte-awesome3.3.5presentation-role-conflict)Downstream follow-up (fount / svelte-jsoneditor#584)
fount Playwright hard-fails on axe hits. Until a fixed
svelte-awesomerelease is consumed bysvelte-jsoneditor/vanilla-jsoneditor:svelte-awesomeinsvelte-jsoneditorvanilla-jsoneditorthat includes itsrc/public/pages/scripts/components/jsonEditor.mjsand remove the temporaryaria-ignorefor issue 584