-
-
Notifications
You must be signed in to change notification settings - Fork 524
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
feat(format/html): implement bracketSameLine #4968
Conversation
write!(f, [soft_line_break_or_space()])?; | ||
} | ||
|
||
// TODO: These tokens (the `/>`) are not yet borrowed by sibling elements for whitespace sensitivity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace sensitivity is not yet implemented for self closing elements
CodSpeed Performance ReportMerging #4968 will not alter performanceComparing Summary
|
e583d33
to
8afc1a8
Compare
8afc1a8
to
b27188e
Compare
This comment was marked as resolved.
This comment was marked as resolved.
b27188e
to
82f9a47
Compare
3f862a2
to
3865b5f
Compare
This comment was marked as resolved.
This comment was marked as resolved.
3865b5f
to
94a7762
Compare
style="color: red" | ||
data-foo="bar" | ||
data-bar="foo" | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need to follow the spec, self closing elements don't exist in HTML. Perhaps we can add another case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self closing elements technically do exist, they are called "void elements" in the spec, and they are defined as elements that have no children, and therefore do not have a closing tag. Syntactically, they do not need the /
and it is ignored by browsers. Prettier always adds the /
for void elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's something we might want to discuss later, but I was thinking of diverging from Prettier and not adding the slash at the end. Maybe we could consider an option in case users want to add them
// TODO: These tokens (the `/>`) are not yet borrowed by sibling elements for whitespace sensitivity. | ||
if slash_token.is_some() { | ||
write!(f, [slash_token.format()])?; | ||
} else { | ||
write!(f, [text("/")])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: A couple things:
- from the Todo, it's not clear what needs to be done
- if possible, I would avoid adding a slash if users didn't add one. Maybe we can iterate this in another issue/pr
94a7762
to
946182e
Compare
Summary
This PR implements functionality for the
bracketSameLine
option, with a particular focus on matching prettier's emitted IR.closes #4024
Test Plan
added tests