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

fix(css/codegen): Preserve raw of numbers #7131

Merged
merged 3 commits into from Mar 23, 2023
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
2 changes: 2 additions & 0 deletions crates/swc_css_codegen/src/lib.rs
Expand Up @@ -1680,6 +1680,8 @@ where
let minified = minify_numeric(n.value);

write_raw!(self, n.span, &minified);
} else if let Some(raw) = &n.raw {
write_raw!(self, n.span, raw);
} else {
write_raw!(self, n.span, &n.value.to_string());
}
Expand Down
4 changes: 2 additions & 2 deletions crates/swc_css_codegen/tests/fixture/function/1/output.css
@@ -1,6 +1,6 @@
div {
color: rgb(255, 255, 255);
color: rgb(255, 255, 255, 0.5);
color: rgb(255, 255, 255, .5);
color: rgb(255 255 255);
color: rgb(255 255 255/ 0.5);
color: rgb(255 255 255/ .5);
}
Expand Up @@ -142,7 +142,7 @@ nav ul li ul {
display: none;
height: auto;
left: -2px;
padding: 0.5rem 1rem;
padding: .5rem 1rem;
position: absolute;
top: 1.7rem;
white-space: nowrap;
Expand Down
Expand Up @@ -254,7 +254,7 @@ html {
}
.pure-u-1-8,
.pure-u-3-24 {
width: 12.5%;
width: 12.5000%;
}
.pure-u-1-6,
.pure-u-4-24 {
Expand All @@ -279,7 +279,7 @@ html {
}
.pure-u-3-8,
.pure-u-9-24 {
width: 37.5%;
width: 37.5000%;
}
.pure-u-2-5 {
width: 40%;
Expand Down Expand Up @@ -307,7 +307,7 @@ html {
}
.pure-u-5-8,
.pure-u-15-24 {
width: 62.5%;
width: 62.5000%;
}
.pure-u-2-3,
.pure-u-16-24 {
Expand All @@ -332,7 +332,7 @@ html {
}
.pure-u-7-8,
.pure-u-21-24 {
width: 87.5%;
width: 87.5000%;
}
.pure-u-11-12,
.pure-u-22-24 {
Expand Down Expand Up @@ -384,7 +384,7 @@ html {
font-family: inherit;
font-size: 100%;
padding: 0.5em 1em;
color: rgba(0, 0, 0, 0.8);
color: rgba(0, 0, 0, 0.80);
border: none rgba(0, 0, 0, 0);
background-color: #e6e6e6;
text-decoration: none;
Expand All @@ -393,16 +393,16 @@ html {
.pure-button-hover,
.pure-button:hover,
.pure-button:focus {
background-image: -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(40%, rgba(0, 0, 0, 0.05)), to(rgba(0, 0, 0, 0.1)));
background-image: linear-gradient(transparent, rgba(0, 0, 0, 0.05) 40%, rgba(0, 0, 0, 0.1));
background-image: -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(40%, rgba(0, 0, 0, 0.05)), to(rgba(0, 0, 0, 0.10)));
background-image: linear-gradient(transparent, rgba(0, 0, 0, 0.05) 40%, rgba(0, 0, 0, 0.10));
}
.pure-button:focus {
outline: 0;
}
.pure-button-active,
.pure-button:active {
-webkit-box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset, 0 0 6px rgba(0, 0, 0, 0.2) inset;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset, 0 0 6px rgba(0, 0, 0, 0.2) inset;
-webkit-box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset, 0 0 6px rgba(0, 0, 0, 0.20) inset;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset, 0 0 6px rgba(0, 0, 0, 0.20) inset;
border-color: #000;
}
.pure-button[disabled],
Expand All @@ -412,7 +412,7 @@ html {
.pure-button-disabled:active {
border: none;
background-image: none;
opacity: 0.4;
opacity: 0.40;
cursor: not-allowed;
-webkit-box-shadow: none;
box-shadow: none;
Expand Down Expand Up @@ -845,18 +845,18 @@ a.pure-button-selected {
white-space: nowrap;
overflow-y: hidden;
overflow-x: auto;
padding: 0.5em 0;
padding: .5em 0;
}
.pure-menu-separator,
.pure-menu-horizontal .pure-menu-children .pure-menu-separator {
background-color: #ccc;
height: 1px;
margin: 0.3em 0;
margin: .3em 0;
}
.pure-menu-horizontal .pure-menu-separator {
width: 1px;
height: 1.3em;
margin: 0 0.3em;
margin: 0 .3em;
}
.pure-menu-horizontal .pure-menu-children .pure-menu-separator {
display: block;
Expand All @@ -874,10 +874,10 @@ a.pure-button-selected {
}
.pure-menu-link,
.pure-menu-heading {
padding: 0.5em 1em;
padding: .5em 1em;
}
.pure-menu-disabled {
opacity: 0.5;
opacity: .5;
}
.pure-menu-disabled .pure-menu-link:hover {
background-color: transparent;
Expand Down