Open WickyNilliams opened 2 years ago
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:
"on"
html`<input type="radio" name="test" .value=${undefined} />` // will submit as string "undefined" html`<input type="radio" name="test" .value=${null} />` // will submit as empty string "" html`<input type="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`<input type="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
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