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
Is your feature request related to a problem? Please describe.
It's irritating that html elements being rendered with attrs get stringified when the value being passed them is falsey. Specifically in the null | undefined | false case. Currently null and undefined act as expected (they just skip the attr), but false gets serialized as "false" which is actually truthy.
<a {href} {download}>Download</a>
Describe the solution you'd like
Treat false like undefined and null are currently. Warn when a non-string value is being automatically stringified for an html element. You almost never want [Object object] in your html. You almost never want the elements of your array indiscriminately joined with commas in your html.
Describe alternatives you've considered
I can easily fix this by using {download || undefined} but I'd really rather not.
How important is this feature to you?
I don't think it's important to me personally because the fix is easy. I do think it's a gotcha that could affect adoption.
<script>
import Link from './Link.svelte'
</script>
<Link href='www.google.com'>Google</Link>
<Link href='https://www.youtube.com/watch?v=dQw4w9WgXcQ' download>Video</Link>
Above, the google link gets a download=false attr, and the video gets a download=true. In both cases they're considered download links. Even worse, passing download={false}still fails the same way.
The text was updated successfully, but these errors were encountered:
As described in this comment and the one after it, treating false as a missing/skipped attribute would probably be a breaking change, and would also prevent the usage Josh mentions in the second comment.
What I recall from going through the known attributes for #3013 is that download is not a boolean attribute, and so doesn't (and shouldn't) have the special handling we have for some other attributes like disabled or selected.
I really don't think we want to change the behavior here, but it should be mentioned somewhere in the docs.
Is your feature request related to a problem? Please describe.
It's irritating that html elements being rendered with attrs get stringified when the value being passed them is falsey. Specifically in the
null | undefined | false
case. Currentlynull
andundefined
act as expected (they just skip the attr), butfalse
gets serialized as"false"
which is actually truthy.<a {href} {download}>Download</a>
Describe the solution you'd like
Treat false like undefined and null are currently. Warn when a non-string value is being automatically stringified for an html element. You almost never want
[Object object]
in your html. You almost never want the elements of your array indiscriminately joined with commas in your html.Describe alternatives you've considered
I can easily fix this by using
{download || undefined}
but I'd really rather not.How important is this feature to you?
I don't think it's important to me personally because the fix is easy. I do think it's a gotcha that could affect adoption.
Additional context
Link.svelte
Consumer.svelte
Above, the google link gets a
download=false
attr, and the video gets adownload=true
. In both cases they're considered download links. Even worse, passingdownload={false}
still fails the same way.The text was updated successfully, but these errors were encountered: