Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ssr omitting bound attribute value 0 #4559

Closed
wants to merge 5 commits into from

Conversation

jonniek
Copy link
Contributor

@jonniek jonniek commented Mar 14, 2020

#4551

Number 0 when used in the value of a binding was ignored by the server side rendering

This issue is most obvious on a non balanced range input with a default value of 0

<script>
    export let inputValue = 0
</script>

<input type="range" bind:value={inputValue} min="0" max="10" />

Before the fix this resulted in a ssr output with no input value which default to look like value 5. With the fix the ssr value is included which fixes the jump from 5 to 0 when client side code would render the input.

Number 0 when used in the value of a binding was
ignored by the server side rendering.
@Conduitry
Copy link
Member

I haven't looked into what exactly is going on here, but at first glance it seems to me that the proper solution would be not to have a special rule about 0 but rather to not have add_attribute called with true for boolean at all.

@jonniek
Copy link
Contributor Author

jonniek commented Mar 14, 2020

Ah that would make sense, I didn't think of trying that since I thought there might have been some important reason to use that flag.

jonniek added 4 commits March 15, 2020 12:46
Drop the boolean flag from add attribute for ssr to
be more explicit. This fixes the issue of rendering
a bound number 0, which was previously omitted.
it was equal to html but to restored to keep diff smaller
@stale
Copy link

stale bot commented Jun 26, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 27, 2021
@jonniek jonniek closed this Jul 13, 2021
@jonniek jonniek deleted the zero-binding-ssr branch July 13, 2021 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants