Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deg and fr as exceptions for 0 value unit omission #2578

Merged
merged 3 commits into from Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/visitor/compiler.js
Expand Up @@ -413,8 +413,8 @@ Compiler.prototype.visitUnit = function(unit){

// Compress
if (this.compress) {
// Always return '0' unless the unit is a percentage or time
if ('%' != type && 's' != type && 'ms' != type && 0 == n) return '0';
// Always return '0' unless the unit is a percentage, time, degree or fraction
if (!(['%', 's', 'ms', 'deg', 'fr'].includes(type)) && 0 == n) return '0';
// Omit leading '0' on floats
if (float && n < 1 && n > -1) {
return n.toString().replace('0.', '.') + type;
Expand Down
2 changes: 1 addition & 1 deletion test/cases/compress.units.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test/cases/compress.units.styl
Expand Up @@ -19,3 +19,13 @@ body
body
foo 0s
foo 0ms

body
foo 0deg
foo 15deg
foo -15deg

body
foo 0fr
foo 15fr
foo -15fr