Giter Club home page Giter Club logo

Comments (11)

IDDT avatar IDDT commented on August 9, 2024 120

<a href={'#'}></a> also removes the warning.

from svelte-spa-router.

emiola avatar emiola commented on August 9, 2024 22

You can also prevent the warning with a comment:

    <!-- svelte-ignore a11y-missing-attribute -->
    <a>...</a>

from svelte-spa-router.

shijiezhou1 avatar shijiezhou1 commented on August 9, 2024 18

<a href={'#'}></a> also removes the warning.

This is awesome I found it super helpful

from svelte-spa-router.

ItalyPaleAle avatar ItalyPaleAle commented on August 9, 2024 15

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.

mholtzhausen avatar mholtzhausen commented on August 9, 2024 9

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) with type="button" instead.

from svelte-spa-router.

DaveVodrazka avatar DaveVodrazka commented on August 9, 2024 6

<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.

ralyodio avatar ralyodio commented on August 9, 2024 5

without href attribute you don't get the proper cursor.

from svelte-spa-router.

CherryDT avatar CherryDT commented on August 9, 2024 3

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.

ItalyPaleAle avatar ItalyPaleAle commented on August 9, 2024

Cursor can be changed with CSS cursor rule

from svelte-spa-router.

 avatar commented on August 9, 2024

<a href={'#'}></a> also removes the warning.

Worked awesome !

from svelte-spa-router.

b1ek avatar b1ek commented on August 9, 2024

use “javascript:void(0)”

don't. that would break most content security policies

from svelte-spa-router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.