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

feat(css/parser): normalize URL function #6675

Merged
merged 3 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 0 additions & 6 deletions crates/swc_css_codegen/tests/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,6 @@ impl VisitMut for NormalizeTest {
n.name.value = n.name.value.to_lowercase().into();
}

fn visit_mut_url(&mut self, n: &mut Url) {
n.visit_mut_children_with(self);

n.name.value = n.name.value.to_lowercase().into();
}

fn visit_mut_pseudo_class_selector(&mut self, n: &mut PseudoClassSelector) {
n.visit_mut_children_with(self);

Expand Down
2 changes: 1 addition & 1 deletion crates/swc_css_minifier/src/compressor/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::Compressor;

impl Compressor {
pub(super) fn compress_url(&self, url: &mut Url) {
if !url.name.value.eq_ignore_ascii_case(&js_word!("url")) {
if url.name.value != js_word!("url") {
return;
}

Expand Down

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_css_parser/src/parser/values_and_units/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2576,7 +2576,7 @@ where

let name = Ident {
span: Span::new(span.lo, span.hi - BytePos(1), Default::default()),
value: function_name,
value: function_name.to_ascii_lowercase(),
raw: Some(raw_function_name),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
"end": 194,
"ctxt": 0
},
"value": "URL",
"value": "url",
"raw": "URL"
},
"value": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
"end": 229,
"ctxt": 0
},
"value": "URL",
"value": "url",
"raw": "URL"
},
"value": {
Expand Down
6 changes: 3 additions & 3 deletions crates/swc_css_parser/tests/fixture/value/url/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
"end": 291,
"ctxt": 0
},
"value": "URL",
"value": "url",
"raw": "URL"
},
"value": {
Expand Down Expand Up @@ -419,7 +419,7 @@
"end": 346,
"ctxt": 0
},
"value": "URL",
"value": "url",
"raw": "\\URL"
},
"value": {
Expand Down Expand Up @@ -1087,7 +1087,7 @@
"end": 948,
"ctxt": 0
},
"value": "SRC",
"value": "src",
"raw": "SRC"
},
"value": {
Expand Down