Skip to content

Fix vue self-closing tags#3693

Merged
azz merged 1 commit intoprettier:masterfrom
azz:vue-selfclose
Jan 10, 2018
Merged

Fix vue self-closing tags#3693
azz merged 1 commit intoprettier:masterfrom
azz:vue-selfclose

Conversation

@azz
Copy link
Copy Markdown
Member

@azz azz commented Jan 10, 2018

Looks like the way the parsing works doesn't add end properties to self-closing tags and their parents (all the way up?). Couldn't figure out a nice way to fix it in the parser so just did it in the printer for now.

Copied in an example component from GitLabHQ.

Fixes #3692

Copy link
Copy Markdown
Contributor

@vjeux vjeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had issues with self closing tags but thought I fixed them... apparently not! Good catch.


// Only force a trailing newline if there were any contents.
if (n.tag === "root" && n.children.length) {
res.push(hardline);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there’s already a trailing (or more) new line, is it going to add one more?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does... I tried to do a right trim on the content but it didn't work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried to normalize this but figured it would not be worth it. I think that the best way forward is to pretty print the first depth of html for vue files. This way we clean up the code a bit more and will handle this newline.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no, it works just fine as is.

@azz azz merged commit b1a7787 into prettier:master Jan 10, 2018
@azz azz deleted the vue-selfclose branch January 10, 2018 07:44
@lock lock Bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 18, 2019
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 18, 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.

Vue self-closing tags cause double-printing

2 participants