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

Support short notation for boolean values (e.g. hx-boost instead of hx-boost="true") #3067

Open
MiErnst opened this issue Dec 11, 2024 · 1 comment

Comments

@MiErnst
Copy link

MiErnst commented Dec 11, 2024

According to the HTML specification for boolean attributes it should be possible to write for example hx-boost (data-hx-boost) instead of hx-boost="true" (data-hx-boost="true").

The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.

@MichaelWest22
Copy link
Contributor

Proper boolean attributes are not supposed to have values of true or false and to always be used just as the existence of the attribute only according to the spec. And hx-boost by default uses inheritance in htmx so needs the false option to operate fully. So I assume it was a deliberate decision to avoid the use and confusion possible with treating it like a boolean attribute.

Hx-preserve is an interesting similar attribute but inheritance was not sensible here and this attribute seems to be implemented with boolean attribute support but it is still common to document it with the same explicit true value to keep things in htmx consistent. But because here there is only one option it was simpler to implement it as a boolean existence check only.

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

No branches or pull requests

2 participants