-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
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>
- (+) Consistent, and thus relatively easy to understand, especially for reset behavior.
- (+) Easy to refactor between checkboxes and switches. (Is this important?)
- (-) Historically, the
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
- (+) 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 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.
Metadata
Metadata
Assignees
Labels
No labels