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 keyframe selector #6688

Merged
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: 1 addition & 1 deletion crates/swc_css_minifier/src/compressor/keyframes.rs
Expand Up @@ -34,7 +34,7 @@ impl Compressor {

pub(super) fn compress_keyframe_selector(&mut self, keyframe_selector: &mut KeyframeSelector) {
match keyframe_selector {
KeyframeSelector::Ident(i) if i.value.eq_ignore_ascii_case(&js_word!("from")) => {
KeyframeSelector::Ident(i) if i.value == js_word!("from") => {
*keyframe_selector = KeyframeSelector::Percentage(Percentage {
span: i.span,
value: Number {
Expand Down
7 changes: 4 additions & 3 deletions crates/swc_css_parser/src/parser/at_rules/mod.rs
Expand Up @@ -896,10 +896,11 @@ where
fn parse(&mut self) -> PResult<KeyframeSelector> {
match cur!(self) {
tok!("ident") => {
let ident: Ident = self.parse()?;
let normalized_ident_value = ident.value.to_ascii_lowercase();
let mut ident: Ident = self.parse()?;

if &*normalized_ident_value != "from" && &*normalized_ident_value != "to" {
ident.value = ident.value.to_ascii_lowercase();

if ident.value != js_word!("from") && ident.value != js_word!("to") {
return Err(Error::new(
ident.span,
ErrorKind::Expected("'from' or 'to' idents"),
Expand Down
Expand Up @@ -1513,7 +1513,7 @@
"end": 686,
"ctxt": 0
},
"value": "fRoM",
"value": "from",
"raw": "fRoM"
}
],
Expand Down Expand Up @@ -1611,7 +1611,7 @@
"end": 737,
"ctxt": 0
},
"value": "tO",
"value": "to",
"raw": "tO"
}
],
Expand Down