Skip to content

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.

@UnknownPlatypus
Copy link
Contributor Author

Hey @g-plane !

Was doing some cleanup on my open pr's, has your position change on this topic?
I still think it would be a nice addition (but should maybe be behind a flag?)

Let me know. I'll be happy to rebase and update this PR

@g-plane
Copy link
Owner

g-plane commented Nov 8, 2025

Let's do it, but not for XML.

@UnknownPlatypus
Copy link
Contributor Author

Awesome, Ill update the pr, I think a few more edge cases need to be handled

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