diff --git a/src/printer.js b/src/printer.js index d175f7719..5da9b179c 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2786,6 +2786,9 @@ function genericPrintNoParens(path, options, print, args) { return concat([n.value, path.call(print, "group")]); } case "value-paren": { + if (n.raws.before !== "") { + return concat([line, n.value]); + } return n.value; } case "value-number": { diff --git a/tests/css_parens/__snapshots__/jsfmt.spec.js.snap b/tests/css_parens/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..cefd9c201 --- /dev/null +++ b/tests/css_parens/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,25 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`parens.js 1`] = ` +a { + box-shadow: inset 0 $size $size (-$size) black; + width: calc(100% - (#{var(--g-spacing)} - #{$iframe-x-padding}) * 2); + padding-right: (100% * $info-width / (1 - $image-width)); + padding-bottom: + ( + 100% * + $image-height / ($image-width-responsive + $image-margin-responsive * 2) + ); +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +a { + box-shadow: inset 0 $size $size (-$size) black; + width: calc(100% - (#{var(--g-spacing)} - #{$iframe-x-padding}) * 2); + padding-right: (100% * $info-width / (1 - $image-width)); + padding-bottom: ( + 100% * + $image-height / ($image-width-responsive + $image-margin-responsive * 2) + ); +} + +`; diff --git a/tests/css_parens/jsfmt.spec.js b/tests/css_parens/jsfmt.spec.js new file mode 100644 index 000000000..a7d303b6c --- /dev/null +++ b/tests/css_parens/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "postcss" }); diff --git a/tests/css_parens/parens.js b/tests/css_parens/parens.js new file mode 100644 index 000000000..4b3adb1da --- /dev/null +++ b/tests/css_parens/parens.js @@ -0,0 +1,10 @@ +a { + box-shadow: inset 0 $size $size (-$size) black; + width: calc(100% - (#{var(--g-spacing)} - #{$iframe-x-padding}) * 2); + padding-right: (100% * $info-width / (1 - $image-width)); + padding-bottom: + ( + 100% * + $image-height / ($image-width-responsive + $image-margin-responsive * 2) + ); +}