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

[fix] collapse whitespace in class / style attribute #6613

Merged
merged 1 commit into from
Aug 20, 2021

Conversation

tanhauhau
Copy link
Member

collapse whitespace within class and style attribute of an element

Fixes #6004

Before submitting the PR, please make sure you do the following

  • Prefix your PR title with [feat], [fix], [chore], or [docs].
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with npm test and lint the project with npm run lint

@Conduitry
Copy link
Member

As I mentioned on the original issue #6004, I still have concerns about forcing this normalization on people, and it sounds like @dummdidumm had concerns too, and the Prettier plugin stopped doing this reformatting because of that.

Maybe we could have this controlled by the same collapseWhitespace option we already have, but that still feels a bit dangerous.

@tanhauhau
Copy link
Member Author

But the collapsing only done for class and style attribute for elements, which shouldn't matter right?

@Conduitry
Copy link
Member

I don't know. I assume dummdidumm had some reason for stopping reformatting class attributes in the Prettier plugin.

@dummdidumm
Copy link
Member

The world has changed, and so has my stance on this. I think collapsing whitespace inside style/class attributes is fine, since according to the spec it doesn't make a difference. The latest version of prettier now even tries to group class attributes by prefixes into multiple lines if it doesn't fit into one line ( prettier/prettier#7865 ; whether to add that to prettier-plugin-svelte is another thing, seems like quite a few people are not happy with it ).

@Conduitry Conduitry merged commit f25a995 into sveltejs:master Aug 20, 2021
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.

Normalize whitespaces in attribute values during compilation
3 participants