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

selected should be a boolean attribute #12023

Closed
1 task done
fviolette opened this issue Sep 18, 2024 · 2 comments · Fixed by #12027
Closed
1 task done

selected should be a boolean attribute #12023

fviolette opened this issue Sep 18, 2024 · 2 comments · Fixed by #12027
Labels
5.0 beta Related to the Astro 5.0 beta - P3: minor bug An edge case that only affects very specific usage (priority) good first issue Good for newcomers. If you need additional guidance, feel free to post in #dev on Discord

Comments

@fviolette
Copy link
Contributor

fviolette commented Sep 18, 2024

Astro Info

Astro                    v5.0.0-beta.1
Node                     v22.8.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             auto-import
                         @astrojs/sitemap
                         @astrojs/preact
                         @astrojs/asides
                         astro-expressive-code
                         @astrojs/pagefind
                         @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When dynamically adding the selected attribute on <option>, Astro preserves the full attribute with its value: selected="true" or selected="false".

On v4.X, selected="true" was output when true and nothing was, when false.

I notice that selected is not part of the list of boolean attributes at: https://github.com/withastro/astro/blob/astro%405.0.0-beta.1/packages/astro/src/runtime/server/render/util.ts#L9

What's the expected result?

As per https://5-0-0-beta.docs.astro.build/en/guides/upgrade-to/v5/#changed-non-boolean-html-attribute-values, I expect the output of selected={true} should be selected, selected={false} should not output anything.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ltqkre?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Sep 18, 2024
@bluwy
Copy link
Member

bluwy commented Sep 19, 2024

Good catch! Looks like an easy fix. I think editing the regex without tests should be fine if you'd like to contribute.

@bluwy bluwy added - P3: minor bug An edge case that only affects very specific usage (priority) good first issue Good for newcomers. If you need additional guidance, feel free to post in #dev on Discord and removed needs triage Issue needs to be triaged labels Sep 19, 2024
@fviolette
Copy link
Contributor Author

Here's my attempt at #12027.

@Princesseuh Princesseuh added the 5.0 beta Related to the Astro 5.0 beta label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 beta Related to the Astro 5.0 beta - P3: minor bug An edge case that only affects very specific usage (priority) good first issue Good for newcomers. If you need additional guidance, feel free to post in #dev on Discord
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants