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
(+) Consistent, and thus relatively easy to understand, especially for reset behavior.
(+) Easy to refactor between checkboxes and switches. (Is this important?)
(-) Historically, the checked="" <-> defaultChecked and nothing <-> checked behavior has been quite confusing for developers. Some frameworks have worked to hide it. Maybe we should not propagate it.
B) Simple mappings
(+) Simpler mental model, matching 99% of all HTML attribute mappings
(+) Allows styling based off of attributes, e.g. #my-switch[checked], instead of pseudo-classes. See Pseudo class for state: should it be :checked? #3. (I think this is a pro because it removes the footgun of trying to use attribute selectors and it only working for default checkedness.)
(+) More generally, storing state in the tree instead of internally makes various operations, e.g. cloning or serializing, simpler for developers.
(-) The usage of defaultchecked="" can be a bit confusing. Especially because you could write <std-switch defaultchecked> (with no checked="" attribute) where it is not checked "by default". Maybe we could fix this by renaming it to checkedafterreset=""?
I think this issue would benefit a lot from web developer feedback.
https://github.com/tkent-google/std-switch/tree/3418f78239e5a99ca6c37099ecb3edfc45e21b29#content-attributes discusses two models for attribute mappings. Here I will list some pros/cons.
A) Compatible with
<input type=checkbox>checked=""<->defaultCheckedand nothing <->checkedbehavior has been quite confusing for developers. Some frameworks have worked to hide it. Maybe we should not propagate it.B) Simple mappings
#my-switch[checked], instead of pseudo-classes. See Pseudo class for state: should it be :checked? #3. (I think this is a pro because it removes the footgun of trying to use attribute selectors and it only working for default checkedness.)defaultchecked=""can be a bit confusing. Especially because you could write<std-switch defaultchecked>(with nochecked=""attribute) where it is not checked "by default". Maybe we could fix this by renaming it tocheckedafterreset=""?I think this issue would benefit a lot from web developer feedback.