File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed
Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -19113,6 +19113,24 @@ mod tests {
1911319113 "#},
1911419114 );
1911519115
19116+ custom_media_test(
19117+ r#"
19118+ @custom-media --not-width not (min-width: 300px);
19119+ @media screen and ((prefers-color-scheme: dark) or (--not-width)) {
19120+ .foo {
19121+ order: 6;
19122+ }
19123+ }
19124+ "#,
19125+ indoc! {r#"
19126+ @media screen and ((prefers-color-scheme: dark) or (not (min-width: 300px))) {
19127+ .foo {
19128+ order: 6;
19129+ }
19130+ }
19131+ "#},
19132+ );
19133+
1911619134 fn custom_media_error_test(source: &str, err: Error<MinifyErrorKind>) {
1911719135 let mut stylesheet = StyleSheet::parse(
1911819136 &source,
Original file line number Diff line number Diff line change @@ -869,8 +869,16 @@ fn process_condition<'i>(
869869 }
870870
871871 // Unwrap nested nots
872- if let MediaCondition :: Not ( cond) = & * * cond {
873- * condition = ( * * cond) . clone ( ) ;
872+ match & * * cond {
873+ MediaCondition :: Not ( cond) => {
874+ * condition = ( * * cond) . clone ( ) ;
875+ }
876+ MediaCondition :: InParens ( parens) => {
877+ if let MediaCondition :: Not ( cond) = & * * parens {
878+ * condition = ( * * cond) . clone ( ) ;
879+ }
880+ }
881+ _ => { }
874882 }
875883 }
876884 MediaCondition :: InParens ( cond) => {
@@ -947,7 +955,11 @@ fn process_condition<'i>(
947955 if r. is_err ( ) {
948956 res = r;
949957 }
950- Some ( condition)
958+ // Parentheses are required around the condition unless there is a single media feature.
959+ match condition {
960+ MediaCondition :: Feature ( ..) | MediaCondition :: InParens ( ..) => Some ( condition) ,
961+ _ => Some ( MediaCondition :: InParens ( Box :: new ( condition) ) ) ,
962+ }
951963 } else {
952964 None
953965 }
You can’t perform that action at this time.
0 commit comments