Skip to content

Commit

Permalink
Fix an issue with space compression in calc values.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-eb committed Sep 17, 2015
1 parent 619bdd8 commit 3c3bbb8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 3.0.2

* Fixes an issue where cssnano was removing spaces around forward slashes in
calc functions.

# 3.0.1

* Replaced css-list & balanced-match with postcss-value-parser, reducing the
Expand Down
5 changes: 4 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ module.exports = postcss.plugin('cssnano-core', function () {
declaration.raws.important = '!important';
}
// Trim unnecessary space around e.g. 12px / 18px
declaration.value = declaration.value.replace(/\s*(\/)\s*/, '$1');
// TODO: This needs proper parsing.
if (!~declaration.value.indexOf('calc')) {
declaration.value = declaration.value.replace(/\s*(\/)\s*/, '$1');
}
if (~[
'outline',
'outline-left',
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/preserveCalcSpaces.expected.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
div{width:calc(100vw / 2 - 6px + 0)}
3 changes: 3 additions & 0 deletions tests/fixtures/preserveCalcSpaces.fixture.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
div {
width: calc(100vw / 2 - 6px + 0);
}

0 comments on commit 3c3bbb8

Please sign in to comment.