Skip to content

Commit

Permalink
Fix empty elements
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Aug 25, 2020
1 parent 7e6d776 commit b44f7e0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/language-html/printer-html.js
Expand Up @@ -87,9 +87,9 @@ function embed(path, print, textToDoc, options) {
return concat([
printOpeningTagPrefix(node, options),
group(printOpeningTag(path, options, print)),
hardline,
doc === "" ? "" : hardline,
doc,
hardline,
doc === "" ? "" : hardline,
printClosingTag(node, options),
printClosingTagSuffix(node, options),
]);
Expand Down
14 changes: 4 additions & 10 deletions tests/vue/multiparser/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -110,9 +110,7 @@ printWidth: 80
=====================================input======================================
<custom lang="markdown"></custom>
=====================================output=====================================
<custom lang="markdown">
</custom>
<custom lang="markdown"></custom>
================================================================================
`;
Expand All @@ -127,14 +125,12 @@ printWidth: 80
</custom>
=====================================output=====================================
<custom lang="markdown">
</custom>
<custom lang="markdown"></custom>
================================================================================
`;
exports[`snippet: new line format 2`] = `
exports[`snippet: non-space format 1`] = `
====================================options=====================================
parsers: ["vue"]
printWidth: 80
Expand All @@ -159,9 +155,7 @@ printWidth: 80
=====================================input======================================
<custom lang="markdown"> </custom>
=====================================output=====================================
<custom lang="markdown">
</custom>
<custom lang="markdown"></custom>
================================================================================
`;
Expand Down
38 changes: 22 additions & 16 deletions tests/vue/multiparser/jsfmt.spec.js
@@ -1,18 +1,24 @@
run_spec({dirname: __dirname, snippets: [
run_spec(
{
name: "empty",
code: '<custom lang="markdown"></custom>'
dirname: __dirname,
snippets: [
{
name: "empty",
code: '<custom lang="markdown"></custom>',
},
{
name: "spaces",
code: '<custom lang="markdown"> </custom>',
},
{
name: "new line",
code: '<custom lang="markdown">\n \n</custom>',
},
{
name: "non-space",
code: '<custom lang="markdown">\n \u2005 \n</custom>',
},
],
},
{
name: "spaces",
code: '<custom lang="markdown"> </custom>'
},
{
name: "new line",
code: '<custom lang="markdown">\n \n</custom>'
},
{
name: "new line",
code: '<custom lang="markdown">\n \u2005 \n</custom>'
},
]}, ["vue"]);
["vue"]
);

0 comments on commit b44f7e0

Please sign in to comment.