Skip to content

feat(html): support custom self-closing tags#5117

Closed
ikatyang wants to merge 2 commits intoprettier:masterfrom
ikatyang:fix/html/custom-self-closing
Closed

feat(html): support custom self-closing tags#5117
ikatyang wants to merge 2 commits intoprettier:masterfrom
ikatyang:fix/html/custom-self-closing

Conversation

@ikatyang
Copy link
Copy Markdown
Member

@ikatyang ikatyang commented Sep 19, 2018

  • switch to @starptech/prettyhtml-parse (a fork of parse5) for preserveSelfClosingCustomTags
  • self-closing HTML tags won't be printed as non-self-closing tags
  • fix some missing cases in feat(html): self-closing for void tags #5116

Prettier pr-5117
Playground link

--parser parse5

Input:

<ABC/>

Output:

<ABC />

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • I’ve read the contributing guidelines.

@ikatyang ikatyang mentioned this pull request Sep 19, 2018
26 tasks
@flxwu
Copy link
Copy Markdown

flxwu commented Sep 20, 2018

This will fix

<div><div class="app" /></div>

turning into

<div>
  <div class="app"></div>
</div>

right?

@ikatyang
Copy link
Copy Markdown
Member Author

@flxwu No, we just preserve it.

Prettier pr-5117
Playground link

--parser parse5

Input:

<div><div class="app" /></div>

Output:

<div>
  <div class="app" />
</div>

@flxwu
Copy link
Copy Markdown

flxwu commented Sep 20, 2018

@ikatyang but wouldn't it be better to auto-collapse self-closing tags?

@alexander-akait
Copy link
Copy Markdown
Member

@flxwu it is break XHTML

@ikatyang ikatyang mentioned this pull request Sep 21, 2018
2 tasks
@ikatyang ikatyang deleted the fix/html/custom-self-closing branch September 22, 2018 13:53
@lipis lipis added this to the 1.15 milestone Oct 26, 2018
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 24, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 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.

4 participants