@@ -19572,6 +19572,61 @@ mod tests {
1957219572 "@container my-layout (inline-size>45em){.foo{color:red}}",
1957319573 );
1957419574
19575+ minify_test(
19576+ r#"
19577+ @container my-layout ( not (width > 500px) ) {
19578+ .foo {
19579+ color: red;
19580+ }
19581+ }
19582+ "#,
19583+ "@container my-layout (not (width>500px)){.foo{color:red}}",
19584+ );
19585+
19586+ minify_test(
19587+ r#"
19588+ @container my-layout not (width > 500px) {
19589+ .foo {
19590+ color: red;
19591+ }
19592+ }
19593+ "#,
19594+ "@container my-layout not (width>500px){.foo{color:red}}",
19595+ );
19596+
19597+ minify_test(
19598+ r#"
19599+ @container not (width > 500px) {
19600+ .foo {
19601+ color: red;
19602+ }
19603+ }
19604+ "#,
19605+ "@container not (width>500px){.foo{color:red}}",
19606+ );
19607+
19608+ minify_test(
19609+ r#"
19610+ @container my-layout ((width: 100px) and (not (height: 100px))) {
19611+ .foo {
19612+ color: red;
19613+ }
19614+ }
19615+ "#,
19616+ "@container my-layout ((width:100px) and (not (height:100px))){.foo{color:red}}",
19617+ );
19618+
19619+ minify_test(
19620+ r#"
19621+ @container my-layout (width = max(10px, 10em)) {
19622+ .foo {
19623+ color: red;
19624+ }
19625+ }
19626+ "#,
19627+ "@container my-layout (width=max(10px,10em)){.foo{color:red}}",
19628+ );
19629+
1957519630 // without name
1957619631 minify_test(
1957719632 r#"
@@ -19595,6 +19650,29 @@ mod tests {
1959519650 "@container (inline-size>45em) and (inline-size<100em){.foo{color:red}}",
1959619651 );
1959719652
19653+ // calc()
19654+ minify_test(
19655+ r#"
19656+ @container (width > calc(100vw - 50px)) {
19657+ .foo {
19658+ color: red;
19659+ }
19660+ }
19661+ "#,
19662+ "@container (width>calc(100vw - 50px)){.foo{color:red}}",
19663+ );
19664+
19665+ minify_test(
19666+ r#"
19667+ @container (calc(100vh - 50px) <= height ) {
19668+ .foo {
19669+ color: red;
19670+ }
19671+ }
19672+ "#,
19673+ "@container (height>=calc(100vh - 50px)){.foo{color:red}}",
19674+ );
19675+
1959819676 // merge adjacent
1959919677 minify_test(
1960019678 r#"
@@ -19652,5 +19730,80 @@ mod tests {
1965219730 minify_test(".foo { width: calc(1cqb + 2cqb) }", ".foo{width:3cqb}");
1965319731 minify_test(".foo { width: calc(1cqmin + 2cqmin) }", ".foo{width:3cqmin}");
1965419732 minify_test(".foo { width: calc(1cqmax + 2cqmax) }", ".foo{width:3cqmax}");
19733+
19734+ // Unlike in @media, there is no need to convert the range syntax in @container,
19735+ // because browsers all support this syntax.
19736+ prefix_test(
19737+ r#"
19738+ @container (width > 100px) {
19739+ .foo { padding: 5px; }
19740+ }
19741+ "#,
19742+ indoc! { r#"
19743+ @container (width > 100px) {
19744+ .foo {
19745+ padding: 5px;
19746+ }
19747+ }
19748+ "#},
19749+ Browsers {
19750+ chrome: Some(105 << 16),
19751+ ..Browsers::default()
19752+ },
19753+ );
19754+ prefix_test(
19755+ r#"
19756+ @container (min-width: 100px) {
19757+ .foo { padding: 5px; }
19758+ }
19759+ "#,
19760+ indoc! { r#"
19761+ @container (min-width: 100px) {
19762+ .foo {
19763+ padding: 5px;
19764+ }
19765+ }
19766+ "#},
19767+ Browsers {
19768+ chrome: Some(105 << 16),
19769+ ..Browsers::default()
19770+ },
19771+ );
19772+
19773+ // Disallow 'none', 'not', 'and', 'or' as a `<container-name>`
19774+ // https://github.com/w3c/csswg-drafts/issues/7203#issuecomment-1144257312
19775+ // https://chromium-review.googlesource.com/c/chromium/src/+/3698402
19776+ error_test(
19777+ "@container none (width < 100vw) {}",
19778+ ParserError::UnexpectedToken(crate::properties::custom::Token::Ident("none".into())),
19779+ );
19780+
19781+ error_test(
19782+ "@container and (width < 100vw) {}",
19783+ ParserError::UnexpectedToken(crate::properties::custom::Token::Ident("and".into())),
19784+ );
19785+
19786+ error_test(
19787+ "@container or (width < 100vw) {}",
19788+ ParserError::UnexpectedToken(crate::properties::custom::Token::Ident("or".into())),
19789+ );
19790+
19791+ // Disallow CSS wide keywords as a `<container-name>`
19792+ error_test(
19793+ "@container revert-layer (width < 100vw) {}",
19794+ ParserError::UnexpectedToken(crate::properties::custom::Token::Ident("revert-layer".into())),
19795+ );
19796+
19797+ error_test(
19798+ "@container initial (width < 100vw) {}",
19799+ ParserError::UnexpectedToken(crate::properties::custom::Token::Ident("initial".into())),
19800+ );
19801+
19802+ // <ident> contains spaces
19803+ // https://github.com/web-platform-tests/wpt/blob/39f0da08fbbe33d0582a35749b6dbf8bd067a52d/css/css-contain/container-queries/at-container-parsing.html#L160-L178
19804+ error_test(
19805+ "@container foo bar (width < 100vw) {}",
19806+ ParserError::UnexpectedToken(crate::properties::custom::Token::Ident("bar".into())),
19807+ );
1965519808 }
1965619809}
0 commit comments