selected
should be a boolean attribute
#12023
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
Astro Info
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"
orselected="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 beselected
,selected={false}
should not output anything.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ltqkre?file=src%2Fpages%2Findex.astro
Participation
The text was updated successfully, but these errors were encountered: