Skip to content

Commit e9b6c28

Browse files
authored
Merge pull request #764 from prettier/allow-ignorable-with-reference
Allow ignoreable whitespace with reference nodes
2 parents 9bb361f + 3912698 commit e9b6c28

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/printer.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ function isWhitespaceIgnorable(opts, name, attributes, content) {
5151
return false;
5252
}
5353

54-
// If there are character data or reference nodes in the content, then we
55-
// can't ignore the whitespace.
56-
if (content.CData.length > 0 || content.reference.length > 0) {
54+
// If there are character data nodes in the content, then we can't ignore the
55+
// whitespace.
56+
if (content.CData.length > 0) {
5757
return false;
5858
}
5959

@@ -342,6 +342,18 @@ function printElementFragments(path, opts, print) {
342342
);
343343

344344
response = response.concat(path.map(printIToken, "PROCESSING_INSTRUCTION"));
345+
346+
response = response.concat(
347+
path.map((referencePath) => {
348+
const referenceNode = referencePath.getValue();
349+
350+
return {
351+
offset: referenceNode.location.startOffset,
352+
printed: print(referencePath)
353+
};
354+
}, "reference")
355+
);
356+
345357
return response;
346358
}
347359

0 commit comments

Comments
 (0)