Skip to content

Discussion issue for attribute mappings #4

@domenic

Description

@domenic

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="" <-> 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions