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/minifier): small bug #6632

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 10 additions & 6 deletions crates/swc_css_minifier/src/compressor/mod.rs
Expand Up @@ -36,7 +36,7 @@ pub fn compressor() -> impl VisitMut {
struct Compressor {
ctx: Ctx,
need_utf8_at_rule: bool,
in_supports_conidition: bool,
in_supports_condition: bool,
kdy1 marked this conversation as resolved.
Show resolved Hide resolved
}

impl Compressor {
Expand Down Expand Up @@ -99,7 +99,7 @@ impl VisitMut for Compressor {
}

fn visit_mut_declaration(&mut self, n: &mut Declaration) {
if self.in_supports_conidition {
if self.in_supports_condition {
n.visit_mut_children_with(self);

return;
Expand Down Expand Up @@ -183,13 +183,13 @@ impl VisitMut for Compressor {
}

fn visit_mut_supports_condition(&mut self, n: &mut SupportsCondition) {
let old_in_support_condition = self.in_supports_conidition;
let old_in_support_condition = self.in_supports_condition;

self.in_supports_conidition = true;
self.in_supports_condition = true;

n.visit_mut_children_with(self);

self.in_supports_conidition = old_in_support_condition;
self.in_supports_condition = old_in_support_condition;

self.compress_supports_condition(n);
}
Expand Down Expand Up @@ -221,14 +221,18 @@ impl VisitMut for Compressor {

// Don't touch `@supports`, it can be used to check a browser's support for one
// or more specific CSS features
if !self.in_supports_conidition {
if !self.in_supports_condition {
self.compress_calc_sum(n);
}
}

fn visit_mut_component_value(&mut self, n: &mut ComponentValue) {
n.visit_mut_children_with(self);

if self.in_supports_condition {
return;
}

self.compress_calc_sum_in_component_value(n);

self.compress_alpha_value_in_component_value(n);
Expand Down
Expand Up @@ -208,3 +208,10 @@
color: red;
}
}

@supports (animation: fade 3s cubic-bezier(0.25, 0.1, 0.25, 1)) {
a {
/* it is safe to compress inside block */
animation: fade 3s cubic-bezier(0.25, 0.1, 0.25, 1)
}
}

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

Expand Up @@ -27,3 +27,9 @@
background: red;
}
}

@supports (width: calc(100px)) {
div {
background: red;
}
}

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