withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.45k stars 2.46k forks source link

add `checked` boolean attribute to `htmlBooleanAttributes` as well #12310

Open dinesh-58 opened 1 day ago

dinesh-58 commented 1 day ago

Astro Info

Astro                    v4.16.7
Node                     v20.11.1
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind

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

No response

Describe the Bug

Basically same as #12023 but for the checked attribute for radio and checkbox inputs. When setting the checked attribute dynamically, checked={true} outputs checked="true" but when its false, it doesn't output anything.

What's the expected result?

This does seem like correct behavior at first glance but the truthy condition should return checked only instead of assigning string values that are considered invalid, as per the html spec. I've added some examples to show that any string value causes checked to be enabled.

Link to Minimal Reproducible Example

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

Participation

dinesh-58 commented 1 day ago

Btw, the commit 1d18bb3 that's linked above shows a warning because I first made the change on a patch branch, then deleted it because I realized it needed to be on main. The correct commit is part of the PR.