Open myFavShrimp opened 4 months ago
This should be a bug in htmx:
When the name
attribute of a button is not set, the name
should be an empty string, not undefined
. Therefore, the default value for name should not be set to undefined
.
In native HTML, using a submit button like <button type="submit" name="" value="">Submit</button>
for submission will not include this empty name in the submitted data. Thus, htmx should filter out empty names to remain consistent with native HTML standards.
Hey, first of all thank you for creating this library!
I am working on a larger project where I use MDUI with HTMX. When sending form data to a server with htmx, the submit button adds an empty field without a value to the request. I created a minimal example to reproduce:
With the above example, here is what the login button looks like in the dom:
HTMX sees the name and the value attributes and includes them in the form data (which is expected behavior with htmx).
Here is what the form data looks like with the code above:
I found an example on the lit.dev playground where the properties of components are defined as optionals. The attributes are not displayed there because they are left
undefined
by default. On theButtonBase
in MDUI the attributes have a default value which is an empty string. I think attributes in MDUI should be made optional as well as empty string values still have a value (which is a string without any characters) whileundefined
is, as far as I know, the expected way to mark something optional in JavaScript.Thanks again for creating MDUI. I hope this can get resolved :slightly_smiling_face: