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
Don't break self closing elements with no attributes #3250
Conversation
// ---------- | ||
x = ( | ||
<p> | ||
text text text text text text text text text text text text text text text<br />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.
To help review, the print width is in the middle of <br />
src/printer.js
Outdated
n.name && n.name.comments && n.name.comments.length; | ||
|
||
// Don't break self-closing elements with no attributes and no comments | ||
if (n.selfClosing && (!n.attributes || !n.attributes.length) && !nameHasComments) { |
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.
As far as I can tell from the next if-statement, n.attributes
is always an array, so there’s no need to check if it exists.
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.
Yeah I was just following some previous code. I never know when properties that can be empty arrays can be undefined.
Fix #3234