Skip to content

Commit

Permalink
Check empty before parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Aug 25, 2020
1 parent bd7eed8 commit 875b478
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/language-html/printer-html.js
Expand Up @@ -78,13 +78,17 @@ function embed(path, print, textToDoc, options) {
return;
}

const doc = textToDoc(
htmlTrimPreserveIndentation(getNodeContent(node, options)),
{ parser },
{ stripTrailingHardline: true }
);

const isEmpty = doc === "" || normalizeDoc(doc).parts.length === 0;
const content = getNodeContent(node, options);
let isEmpty = /^\s*$/.test(content);
let doc = "";
if (!isEmpty) {
doc = textToDoc(
htmlTrimPreserveIndentation(content),
{ parser },
{ stripTrailingHardline: true }
);
isEmpty = doc === "" || normalizeDoc(doc).parts.length === 0;
}

return concat([
printOpeningTagPrefix(node, options),
Expand Down

0 comments on commit 875b478

Please sign in to comment.