ember-estree 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/print.js +13 -2
package/package.json
CHANGED
package/src/print.js
CHANGED
|
@@ -831,8 +831,19 @@ export function print(node) {
|
|
|
831
831
|
|
|
832
832
|
case "GlimmerAttrNode": {
|
|
833
833
|
const name = node.name ?? "";
|
|
834
|
-
const value =
|
|
835
|
-
|
|
834
|
+
const value = node.value;
|
|
835
|
+
// A plain text value carries no quote style in the AST, so quote it
|
|
836
|
+
// (always valid) — printing it raw drops the quotes and corrupts any
|
|
837
|
+
// value with whitespace, e.g. `data-x="a b"` -> `data-x=a b`. An empty
|
|
838
|
+
// text value is a valueless attribute (`<input disabled>`).
|
|
839
|
+
if (value?.type === "GlimmerTextNode") {
|
|
840
|
+
const chars = value.chars ?? "";
|
|
841
|
+
if (chars === "") return name;
|
|
842
|
+
const quote = chars.includes('"') ? "'" : '"';
|
|
843
|
+
return `${name}=${quote}${chars}${quote}`;
|
|
844
|
+
}
|
|
845
|
+
// Mustache (`{{x}}`) and concat (`"a {{b}}"`) values print themselves.
|
|
846
|
+
return `${name}=${print(value)}`;
|
|
836
847
|
}
|
|
837
848
|
|
|
838
849
|
case "GlimmerConcatStatement": {
|