Am I wrong or this should remove href attribute from the a tag?
<a href={false}></a>
It doesn't ("svelte": "3.44.2").
The docs say
Boolean attributes are included on the element if their value is truthy and excluded if it's falsy.
All other attributes are included unless their value is nullish (null or undefined).
href= is no boolean attribute, so false doesn't work, use null/undefined instead
<a href={null}>linkText</a>
<a href={undefined} >linkText</a>
Use null and it will deactivate the hyperlink and won't go anywhere.
Or you can add on:click|preventDefault to the anchor.
<a href={null} on:click|preventDefault>link</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With