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
I haven't tested with different cases yet, but assigning an anchor tag's href using a destructured object does not appear to mitigate missing attribute warnings.
Reproduction
For illustration:
<scriptlang="ts">
const attributes = { href: '/about' }
</script>
<nav>
<a {...attributes}>About</a> <!-- A11y: <a> element should have an href attributesvelte(a11y-missing-attribute) -->
</nav>
Cases like the above will quickly be met when using an approach similar to melt-ui's builders to manage an element's attributes. For example, in my app I have a series of small i18n helpers that localize anchor hrefs (prepending the locale param) and specify their corresponding hreflang attribute:
<nav>
<a {...$i18nlink('/about')}>{t('about')}</a> <!-- A11y: <a> element should have an href attributesvelte(a11y-missing-attribute) -->
<ahref={$i18nhref('/projects')} hreflang={$page.data.locale}>{t('projects')}</a>
</nav>
where i18nlink is a derived store returning an object {href: string, hreflang: string}.
Expected behaviour
If destructured object used for element attributes contains expected attribute keys (for example href on an anchor tag), omit warning.
System Info
OS: MacOS
IDE: VSCode
Which package is the issue about?
Svelte for VS Code extension
Additional Information, eg. Screenshots
No response
The text was updated successfully, but these errors were encountered:
We're not, in general, going to be able to tell at compile time whether a given attribute is going to be present. I guess the question, then, is whether we ought to disable all missing-attribute a11y warnings for a given element when it has spread attributes. And I don't know what my answer is to that.
My vote would be to not throw the warning if the element has a spread attribute. In the past we've seemed to opt for false negatives over false positives and this would be in line with that.
Describe the bug
I haven't tested with different cases yet, but assigning an anchor tag's
href
using a destructured object does not appear to mitigate missing attribute warnings.Reproduction
For illustration:
Cases like the above will quickly be met when using an approach similar to melt-ui's builders to manage an element's attributes. For example, in my app I have a series of small i18n helpers that localize anchor
hrefs
(prepending the locale param) and specify their correspondinghreflang
attribute:where
i18nlink
is a derived store returning an object{href: string, hreflang: string}
.Expected behaviour
If destructured object used for element attributes contains expected attribute keys (for example
href
on an anchor tag), omit warning.System Info
Which package is the issue about?
Svelte for VS Code extension
Additional Information, eg. Screenshots
No response
The text was updated successfully, but these errors were encountered: