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

Wrong server-side rendering of attributes when value is true #6121

Closed
Pierrci opened this issue Mar 23, 2021 · 6 comments · Fixed by #7066
Closed

Wrong server-side rendering of attributes when value is true #6121

Pierrci opened this issue Mar 23, 2021 · 6 comments · Fixed by #7066

Comments

@Pierrci
Copy link

Pierrci commented Mar 23, 2021

Describe the bug
When passing a true value to a custom data attribute (e.g. data-active) in SSR, it renders data-active="".

To Reproduce

<script>
	let content = true;
</script>

<div data-active={content}></div>

Expected behavior
I'm only expecting an attribute to be rendered as attr="" when the value passed to it is true if it's a boolean attribute. In the case of any other attribute, attr="true" should be rendered instead (as it is when using DOM rendering).

Stacktraces
It's easy to see the origin of the problem, at https://github.com/sveltejs/svelte/blob/master/src/runtime/internal/ssr.ts#L130-L133

Severity
Annoying, particularly because of the inconsistency for such attributes between SSR and DOM rendering. For now we're writing things like data-active={value === true ? 'true' : false} as a workaround.

I can open a PR to fix this behavior if it's ok for you :)

@stale
Copy link

stale bot commented Jun 26, 2021

This issue 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
@julien-c
Copy link

I can confirm we are affected by this at @huggingface

@stale
Copy link

stale bot commented Dec 26, 2021

This issue 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 Dec 26, 2021
@julien-c
Copy link

unstale, and cc'ing @pngwn on this =)

@stale stale bot removed the stale-bot label Dec 27, 2021
@bluwy
Copy link
Member

bluwy commented Dec 28, 2021

I can open a PR to fix this behavior if it's ok for you :)

Yes feel free to open a PR

@Conduitry
Copy link
Member

This should be fixed now in 3.45.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants