Comments (11)
<a href={'#'}></a>
also removes the warning.
from svelte-spa-router.
You can also prevent the warning with a comment:
<!-- svelte-ignore a11y-missing-attribute -->
<a>...</a>
from svelte-spa-router.
<a href={'#'}></a>
also removes the warning.
This is awesome I found it super helpful
from svelte-spa-router.
This is not an issue with the router. It’s Svelte telling you that links to # are bad for accessibility.
If you want to link to the home page, use #/ for href. If you want a link that does nothing, use “javascript:void(0)” for href. Or just don’t use an anchor tag and use any other kind of tag :)
from svelte-spa-router.
In most cases where this is an issue, it is intercepted with on:click
handler to perform some action.
There is an accessibility issue with providing a link, if a screen-reader can't read where it is going - so links must always be clear in what they're attempting to link to.
When you intercept an on:click
action like that though, you're most likely not trying to really create a link, you're just using it because it is a convenient click-able to trigger your action.
The real solution here is to use a button
. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role :
The button role identifies an element as a button to assistive technology such as screen readers. A button is a widget used to perform actions such as submitting a form, opening a dialog, canceling an action, or performing a command such as inserting a new record or displaying information. Adding role="button" tells assistive technology that the element is a button but provides no button functionality. Use or
input
(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) withtype="button"
instead.
from svelte-spa-router.
<a href={'#'}> also removes the warning.
This indeed does remove the warning, but does not solve the problem of an invalid href for a11y
purposes.
I would suggest using <a href="#top"></a>
, clearly stating where the link leads.
from svelte-spa-router.
without href attribute you don't get the proper cursor.
from svelte-spa-router.
If you want a link that does nothing, use “javascript:void(0)” for href.
The problem with this is that with strict content security policy (which is recommended) it will generate CSP warnings and send CSP audit reports for no reason.
from svelte-spa-router.
Cursor can be changed with CSS cursor rule
from svelte-spa-router.
<a href={'#'}></a>
also removes the warning.
Worked awesome !
from svelte-spa-router.
use “javascript:void(0)”
don't. that would break most content security policies
from svelte-spa-router.
Related Issues (20)
- a11y warnings HOT 1
- Active links - allow duplicate classes
- In vite, i can't use the proxy /dev HOT 1
- Redirection from route pre-condition HOT 5
- Nested routes as maps HOT 1
- If I want to go to the login page in the sidebar + SPA form, is it possible with route guard? HOT 4
- Is this not possible in routeLoaded? HOT 5
- What is the black bar in this image? HOT 2
- Feature request: Svelte 4 support HOT 13
- FEATURE REQUEST: pass next() in precondition to decide whether the router should *change* the current route HOT 1
- Load user data HOT 4
- How to check hash-bashed history HOT 1
- Is there an alternative to the "Failed to fetch dynamically import problem" issue in Vite + Svelte spa environment? HOT 1
- WARNING: The following packages have a svelte field in their package.json but no exports condition for svelte. [email protected] HOT 8
- Typescript problematic types after "wrapping" the route HOT 2
- navigating within same component does not work HOT 5
- Typescript support: Package path ./wrap is not exported from package svelte-spa-router HOT 2
- Will the library support Svelte 5? HOT 5
- Authentication and Authorization HOT 6
- Layouts not exists for svelte-spa-router? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-spa-router.