diff --git a/src/language-css/parser-postcss.js b/src/language-css/parser-postcss.js index 97e7cf73..003f53b5 100644 --- a/src/language-css/parser-postcss.js +++ b/src/language-css/parser-postcss.js @@ -347,7 +347,7 @@ function parseNestedCSS(node) { // Remove unnecessary spaces in SCSS variable arguments node.params = node.params.replace(/\s+\.\.\./, "..."); // Remove unnecessary spaces before SCSS control, mixin and function directives - node.params = node.params.replace(/^(\S+)\s+\(/, "$1("); + node.params = node.params.replace(/^(?!if)(\S+)\s+\(/, "$1("); node.value = parseValue(node.params); delete node.params; diff --git a/tests/css_atrule/__snapshots__/jsfmt.spec.js.snap b/tests/css_atrule/__snapshots__/jsfmt.spec.js.snap index 5eda363d..a74c4881 100644 --- a/tests/css_atrule/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css_atrule/__snapshots__/jsfmt.spec.js.snap @@ -2005,6 +2005,7 @@ p { @if $base-font-size != 16px or $base-line-height != 24px or $base-unit != 'em' or $h1-font-size != 2 * $base-font-size or $h2-font-size != 1.5 * $base-font-size or $h3-font-size != 1.17 * $base-font-size or $h4-font-size != 1 * $base-font-size or $h5-font-size != 0.83 * $base-font-size or $h6-font-size != 0.67 * $base-font-size or $indent-amount != 40px {} @if (str-slice($item, 0, 1) == ":") {} @if (str-slice($item, 0, 3) == " : ") {} + @if ($type == ocean) {} @else if ($type == matador) {} @else {} } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @if $media == phonePortrait { @@ -2132,6 +2133,10 @@ p { } @if (str-slice($item, 0, 3) == " : ") { } + @if ($type == ocean) { + } @else if ($type == matador) { + } @else { + } } `; diff --git a/tests/css_atrule/if-else.css b/tests/css_atrule/if-else.css index 7c2f39b6..df7c6e6a 100644 --- a/tests/css_atrule/if-else.css +++ b/tests/css_atrule/if-else.css @@ -141,4 +141,5 @@ p { @if $base-font-size != 16px or $base-line-height != 24px or $base-unit != 'em' or $h1-font-size != 2 * $base-font-size or $h2-font-size != 1.5 * $base-font-size or $h3-font-size != 1.17 * $base-font-size or $h4-font-size != 1 * $base-font-size or $h5-font-size != 0.83 * $base-font-size or $h6-font-size != 0.67 * $base-font-size or $indent-amount != 40px {} @if (str-slice($item, 0, 1) == ":") {} @if (str-slice($item, 0, 3) == " : ") {} + @if ($type == ocean) {} @else if ($type == matador) {} @else {} }