Skip to content

Commit

Permalink
Fix ignored element print (#7867)
Browse files Browse the repository at this point in the history
* Fix ignored element print

* Add changelog
  • Loading branch information
fisker committed Mar 25, 2020
1 parent 2fc35d2 commit 77e3fc0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
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

0 comments on commit 77e3fc0

Please sign in to comment.