diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js
index 27167a80..b215fa67 100644
--- a/src/language-js/printer-estree.js
+++ b/src/language-js/printer-estree.js
@@ -364,7 +364,21 @@ function printTernaryOperator(path, options, print, operatorOptions) {
return maybeGroup(
concat(
[].concat(
- operatorOptions.beforeParts(),
+ (testDoc =>
+ /**
+ * a
+ * ? b
+ * : multiline
+ * test
+ * node
+ * ^^ align(2)
+ * ? d
+ * : e
+ */
+ parent.type === operatorOptions.conditionalNodeType &&
+ parent[operatorOptions.alternateNodePropertyName] === node
+ ? align(2, testDoc)
+ : testDoc)(concat(operatorOptions.beforeParts())),
forceNoIndent ? concat(parts) : indent(concat(parts)),
operatorOptions.afterParts(breakClosingParen)
)
diff --git a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap
index 5f2cb1bd..28a329c0 100644
--- a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap
@@ -1599,7 +1599,16 @@ const foo =
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+a
+ ? literalline
+ : {
+ 123: 12
+ }
+ ? line
+ : softline
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let icecream =
what == "cone"
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
@@ -1689,6 +1698,14 @@ const foo = (
);
+a
+ ? literalline
+ : {
+ 123: 12
+ }
+ ? line
+ : softline;
+
`;
exports[`nested.js - flow-verify 2`] = `
@@ -1778,7 +1795,16 @@ const foo = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+a
+ ? literalline
+ : {
+ 123: 12
+ }
+ ? line
+ : softline
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let icecream =
what == "cone"
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
@@ -1868,6 +1894,14 @@ const foo = (
);
+a
+ ? literalline
+ : {
+ 123: 12
+ }
+ ? line
+ : softline;
+
`;
exports[`nested.js - flow-verify 3`] = `
@@ -1957,7 +1991,16 @@ const foo = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+a
+ ? literalline
+ : {
+ 123: 12
+ }
+ ? line
+ : softline
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let icecream =
what == "cone"
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
@@ -2047,6 +2090,14 @@ const foo = (
);
+a
+ ? literalline
+ : {
+ 123: 12
+ }
+ ? line
+ : softline;
+
`;
exports[`nested.js - flow-verify 4`] = `
@@ -2136,7 +2187,16 @@ const foo = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+a
+ ? literalline
+ : {
+ 123: 12
+ }
+ ? line
+ : softline
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let icecream =
what == "cone"
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
@@ -2226,6 +2286,14 @@ const foo = (
);
+a
+ ? literalline
+ : {
+ 123: 12
+ }
+ ? line
+ : softline;
+
`;
exports[`parenthesis.js - flow-verify 1`] = `
diff --git a/tests/ternaries/nested.js b/tests/ternaries/nested.js
index df6d12c2..7b47011e 100644
--- a/tests/ternaries/nested.js
+++ b/tests/ternaries/nested.js
@@ -84,4 +84,12 @@ const foo =
\ No newline at end of file
+
+
+a
+ ? literalline
+ : {
+ 123: 12
+ }
+ ? line
+ : softline