You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checkboxes and radios are unique in that they have a default value of "on". If you use property binding, you cannot take advantage of this:
html`<inputtype="radio" name="test" .value=${undefined}/>`// will submit as string "undefined"html`<inputtype="radio" name="test" .value=${null}/>`// will submit as empty string ""html`<inputtype="radio" name="test" .value=${""}/>`// will submit as empty string ""
Whereas if you use the attribute binding, you can conditionally render the attribute and fallback to the default:
html`<inputtype="radio" name="test" value=${ifDefined(value)}/>`// will submit as "on"
In my testing this works correctly even if a value is initially set, and later changed, or if attribute is later removed.
Happy to attempt a PR if you don't object
The text was updated successfully, but these errors were encountered:
Checkboxes and radios are unique in that they have a default value of
"on"
. If you use property binding, you cannot take advantage of this:Whereas if you use the attribute binding, you can conditionally render the attribute and fallback to the default:
In my testing this works correctly even if a value is initially set, and later changed, or if attribute is later removed.
Happy to attempt a PR if you don't object
The text was updated successfully, but these errors were encountered: