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

Fix ignored element print #7867

Merged
merged 2 commits into from Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions changelog_unreleased/html/pr-7867.md
@@ -0,0 +1,23 @@
#### Fix ignored empty inline element print ([#7867](https://github.com/prettier/prettier/pull/7867) by [@fisker](https://github.com/fisker))

<!-- prettier-ignore -->
```html
<!--Input-->
<!--prettier-ignore--><span></span>
<!--prettier-ignore--><span>_</span>

<!--Prettier stable-->
<!--prettier-ignore--><span
></span>
<!--prettier-ignore--><span>_</span>

<!--Prettier stable (Second format)-->
<!--prettier-ignore--><span

></span>
<!--prettier-ignore--><span>_</span>

<!--Prettier master-->
<!--prettier-ignore--><span></span>
<!--prettier-ignore--><span>_</span>
```
13 changes: 7 additions & 6 deletions src/language-html/printer-html.js
Expand Up @@ -554,12 +554,13 @@ function printChildren(path, options, print) {
? hardline
: softline
: (needsToBorrowNextOpeningTagStartMarker(prevNode) &&
/**
* 123<a
* ~
* ><b>
*/
(nextNode.firstChild ||
(hasPrettierIgnore(nextNode) ||
/**
* 123<a
* ~
* ><b>
*/
nextNode.firstChild ||
/**
* 123<!--
* ~
Expand Down
3 changes: 1 addition & 2 deletions tests/html_prettier_ignore/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -14,8 +14,7 @@ printWidth: 80
123<!--prettier-ignore-->456
<span></span
><!--prettier-ignore--><span
></span>
><!--prettier-ignore--><span></span>
================================================================================
`;
Expand Down
1 change: 0 additions & 1 deletion tests_config/run_spec.js
Expand Up @@ -34,7 +34,6 @@ const unstableTests = new Map(
"html_angular/attributes.component.html",
(options) => options.printWidth === 1,
],
"html_prettier_ignore/cases.html",
"js_empty/semicolon.js",
"jsx_ignore/jsx_ignore.js",
"markdown_footnoteDefinition/multiline.md",
Expand Down