Skip to content

Commit

Permalink
fix: units being removed in math functions (#894)
Browse files Browse the repository at this point in the history
  • Loading branch information
wongjn committed Apr 1, 2020
1 parent 09bdf86 commit 1ccbd5b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,15 @@
"contributions": [
"platform"
]
},
{
"login": "wongjn",
"name": "wongjn",
"avatar_url": "https://avatars2.githubusercontent.com/u/11310624?v=4",
"profile": "https://github.com/wongjn",
"contributions": [
"code"
]
}
],
"repoType": "github"
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ module.exports = {
'_processCss.js',
'_webpack.config.js',
],
testTimeout: 30000,
};
6 changes: 6 additions & 0 deletions packages/postcss-convert-values/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ test(
passthroughCSS('h1{line-height:0rem}')
);

test('should keep unit in max()', passthroughCSS('h1{margin:max(0px)}'));

test('should keep unit in min()', passthroughCSS('h1{margin:min(0px)}'));

test('should keep unit in clamp()', passthroughCSS('h1{margin:clamp(0px)}'));

test(
'should keep unknown units or hacks',
passthroughCSS('h1{top:0\\9\\0;left:0lightyear}')
Expand Down
7 changes: 6 additions & 1 deletion packages/postcss-convert-values/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ function transform(opts, decl) {
});
return false;
}
if (lowerCasedValue === 'url') {
if (
lowerCasedValue === 'url' ||
lowerCasedValue === 'min' ||
lowerCasedValue === 'max' ||
lowerCasedValue === 'clamp'
) {
return false;
}
}
Expand Down

0 comments on commit 1ccbd5b

Please sign in to comment.