Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize accept HTML attribute value as a comma separated string #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

UnknownPlatypus
Copy link
Contributor

@UnknownPlatypus UnknownPlatypus commented Aug 6, 2024

The html accept attribute expect a comma separated list of string.
This is easy to normalize the same way we normalize class as a space-separated list of string so I went for it.

This could possibly be expanded to other attribute with defined semantics (See #40 (comment)).

-<input type="file" accept=" image/gif
-                               , image/jpeg ">
+<input type="file" accept="image/gif, image/jpeg">

@g-plane
Copy link
Owner

g-plane commented Aug 7, 2024

I'm neutral on this, so I'm going to leave it open for discussions.

@UnknownPlatypus
Copy link
Contributor Author

For context this is tracked more generally in prettier too Format values of attributes with defined semantics and led to the formatting of class and style attributes.

I've also done some research for other good candidates from the HTML attribute list (cross referencing the HTML spec) and found the followings that could be formatted space-separated like class:

  • rel on "form", "a", "area", "link"
  • autocomplete on "form", "input", "select", "textarea"
  • sandbox on "iframe"
  • accept-charset on "form"
  • aria-labelledby, aria-describedby, aria-controls and aria-owns on any element

Quick searches using https://sourcegraph.com/search found matches with weird spaces for all of them so I suppose it could benefit some people.

@Hebilicious
Copy link

I personally love this as a default, but perhaps having an option to disable it would be useful for some users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants