-
-
Notifications
You must be signed in to change notification settings - Fork 180
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Bug Report
- datastar special cases the "value" attribute of input elements; when patching elements, if an
<input>has a changed "value", a corresponding change is made to the input's value property. - datastar does not similarly special case the "checked" attribute of input elements; when patching elements, if an input's "checked" attribute has changed, the input's "checked" property is not updated.
- "value" and "checked" are similarly defined in the html spec (https://html.spec.whatwg.org/#attr-input-value); the spec suggests no reason d* should handle them differently.
A change that that would resolve this inconsistency:
- datastar should special-case the input attributes "checked" and "disabled" the same way it currently special cases "value".
- datastar should also special case the
<option>"selected" attribute, which is described in the html spec similarly to input.value and input.checked. - in case it's helpful, this file shows what elements and attributes morphdom handles specially: https://github.com/patrick-steele-idem/morphdom/blob/master/src/specialElHandlers.js
These changes would simplify the HTML included in some patch-elements events. Instead of toggling a checkbox with:
<input type="checkbox" data-on-load="el.checked = true;" />users could write:
<input type="checkbox" checked />This also seems like a more intuitive behavior. It seems unlikely someone would send down <input type="checkbox" checked /> and only want to change the default checkedness of the input.
Datastar Version
v1 rc 5
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request