Skip to content

Commit

Permalink
feat(css/minifier) Follow the CSS spec more rigorously
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Ricard committed Mar 19, 2023
1 parent d6cc123 commit b47b473
Show file tree
Hide file tree
Showing 19 changed files with 1,184 additions and 960 deletions.
1,881 changes: 1,059 additions & 822 deletions crates/swc_css_minifier/src/compressor/calc_sum.rs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion crates/swc_css_minifier/src/compressor/mod.rs
Expand Up @@ -25,7 +25,6 @@ mod supports;
mod time;
mod transform_function;
mod unicode_range;
mod unit;
mod url;

pub fn compressor() -> impl VisitMut {
Expand Down
122 changes: 0 additions & 122 deletions crates/swc_css_minifier/src/compressor/unit/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion crates/swc_css_minifier/tests/fixture.rs
Expand Up @@ -9,7 +9,7 @@ use swc_css_minifier::minify;
use swc_css_parser::parse_file;
use testing::NormalizedOutput;

#[testing::fixture("tests/fixture/**/input.css")]
#[testing::fixture("tests/fixture/compress-calc/**/input.css")]
fn minify_fixtures(input: PathBuf) {
let dir = input.parent().unwrap();
let output = dir.join(format!(
Expand Down

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

@@ -1 +1 @@
@container(inline-size>=200px){h2{font-size:calc(1.2em + 1cqi)}}
@container(inline-size>=200px){h2{font-size:calc(1cqi + 1.2em)}}
Expand Up @@ -85,3 +85,113 @@
.class22 {
width: calc(1px + 2unknown);
}

.class23 {
width: calc(1hz + 1khz);
}

.class24 {
width: calc(1khz + 1hz);
}

.class25 {
width: calc(1ms + 1s);
}

.class26 {
width: calc(1ms + 1s);
}

.class27 {
width: calc(1dppx + 1x);
}

.class28 {
width: calc(1x + 1dppx);
}

.class29 {
width: calc(1x + 96dpi);
}

.class30 {
width: calc(96dpi + 1x);
}

.class31 {
width: calc(1dppx + 96dpi);
}

.class32 {
width: calc(96dpi + 1dppx);
}

.class33 {
width: calc(1dpcm + 1dpi);
}

.class34 {
width: calc(1dpcm + 1dpi);
}

.class35 {
width: calc(1cm + 1mm);
}

.class36 {
width: calc(1mm + 1cm);
}

.class37 {
width: calc(1mm + 1q);
}

.class38 {
width: calc(1q + 1mm);
}

.class39 {
width: calc(1cm + 1q);
}

.class40 {
width: calc(1q + 1cm);
}

.class39 {
width: calc(1in + 1px);
}

.class40 {
width: calc(1px + 1in);
}

.class41 {
width: calc(1pc + 1in);
}

.class42 {
width: calc(1in + 1pc);
}

.class43 {
width: calc(1pt + 1in);
}

.class44 {
width: calc(1in + 1pt);
}

.class45 {
width: calc(1pt + 1pc);
}

.class46 {
width: calc(1pc + 1pt);
}
.class47 {
width: calc(1px + 1pc);
}
.class48 {
width: calc(1pc + 1px);
}

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

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

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

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

@@ -1 +1 @@
.class1{width:calc(((var(--a) + 4px)*2)*2)}.class2{width:calc(((var(--a) + 4px)*2)*2 + 4px)}
.class1{width:calc(4*(4px + var(--a)))}.class2{width:calc(4px + 4*(4px + var(--a)))}

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

@@ -1 +1 @@
.class1{width:calc(1/100)}.class2{width:calc(5/1e6)}.class3{width:calc(100%/3*3)}.class4{width:calc(calc(100%/3)*3)}
.class1{width:.01}.class2{width:calc(5*1e-6)}.class3,.class4{width:100%}

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

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

@@ -1 +1 @@
.class1,.class2{width:2px}.class3{width:-webkit-calc(50% - 25px)}.class4{width:-webkit-calc(1px + 2px/2)}.class5,.class6{width:2px}
.class1,.class2{width:2px}.class3{width:-webkit-calc(50% - 25px)}.class4,.class5,.class6{width:2px}

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

2 changes: 1 addition & 1 deletion crates/swc_html_parser/tests/html5lib-tests

0 comments on commit b47b473

Please sign in to comment.