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

Don't break self closing elements with no attributes #3250

Merged
merged 5 commits into from Nov 13, 2017

Conversation

duailibe
Copy link
Member

Fix #3234

// ----------
x = (
<p>
text text text text text text text text text text text text text text text<br />text
Copy link
Member Author

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) {
Copy link
Member

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.

Copy link
Member Author

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.

@duailibe duailibe merged commit 482c83d into prettier:master Nov 13, 2017
@duailibe duailibe deleted the jsx-br branch November 13, 2017 04:20
@suchipi suchipi added this to the 1.9 milestone Nov 28, 2017
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants