diff --git a/README.md b/README.md index facb9ebb..63770060 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,8 @@ Configuration items are: ## News and noteworthy +* v6.3.3 - 2021-05-31 + * Allow unknown rules inside `@media` rules ([issue #67](https://github.com/phax/ph-css/issues/67)) - thanks @yinkwok-ys * v6.3.2 - 2021-05-25 * Fixed an error with the negation parameters ([issue #66](https://github.com/phax/ph-css/issues/66)) - thanks @rockwotj * v6.3.1 - 2021-05-02 diff --git a/ph-css/src/test/java/com/helger/css/reader/CSSReader30SpecialFuncTest.java b/ph-css/src/test/java/com/helger/css/reader/CSSReader30SpecialFuncTest.java index b31c9ec5..c50f9e4d 100644 --- a/ph-css/src/test/java/com/helger/css/reader/CSSReader30SpecialFuncTest.java +++ b/ph-css/src/test/java/com/helger/css/reader/CSSReader30SpecialFuncTest.java @@ -37,7 +37,6 @@ import com.helger.css.decl.CSSExpressionMemberMath; import com.helger.css.decl.CSSExpressionMemberTermSimple; import com.helger.css.decl.CSSExpressionMemberTermURI; -import com.helger.css.decl.CSSMediaRule; import com.helger.css.decl.CSSPageMarginBlock; import com.helger.css.decl.CSSPageRule; import com.helger.css.decl.CSSStyleRule; @@ -358,32 +357,6 @@ public void testReadSingleLineComments () assertEquals (1, aCSS.getStyleRuleAtIndex (12).getDeclarationCount ()); } - @Test - public void testIssue67 () - { - final String sCSS = "@media (max-width: 959px) {\r\n" + - " @-moz-document url-prefix() {\r\n" + - " .test-class {\r\n" + - " height: 1vh;\r\n" + - " visibility: collapse;\r\n" + - " }\r\n" + - " }\r\n" + - "}\r\n" + - "\r\n" + - "@-moz-anything {}"; - final CascadingStyleSheet aCSS = CSSReader.readFromString (sCSS, ECSSVersion.LATEST); - assertNotNull (aCSS); - assertEquals (2, aCSS.getRuleCount ()); - assertEquals (1, aCSS.getMediaRuleCount ()); - assertEquals (1, aCSS.getUnknownRuleCount ()); - - final CSSMediaRule aMR = aCSS.getMediaRuleAtIndex (0); - assertNotNull (aMR); - - assertEquals (1, aMR.getRuleCount ()); - assertEquals (1, aMR.getUnknownRuleCount ()); - } - @Test public void testReadFootnote () { diff --git a/ph-css/src/test/java/com/helger/css/supplementary/issues/Issue67Test.java b/ph-css/src/test/java/com/helger/css/supplementary/issues/Issue67Test.java new file mode 100644 index 00000000..bb936563 --- /dev/null +++ b/ph-css/src/test/java/com/helger/css/supplementary/issues/Issue67Test.java @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2014-2021 Philip Helger (www.helger.com) + * philip[at]helger[dot]com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.helger.css.supplementary.issues; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +import com.helger.css.ECSSVersion; +import com.helger.css.decl.CSSMediaRule; +import com.helger.css.decl.CascadingStyleSheet; +import com.helger.css.reader.CSSReader; + +/** + * Test for issue 61: https://github.com/phax/ph-css/issues/67 + * + * @author Philip Helger + */ +public final class Issue67Test +{ + @Test + public void testIssue67 () + { + final String sCSS = "@media (max-width: 959px) {\r\n" + + " @-moz-document url-prefix() {\r\n" + + " .test-class {\r\n" + + " height: 1vh;\r\n" + + " visibility: collapse;\r\n" + + " }\r\n" + + " }\r\n" + + "}\r\n" + + "\r\n" + + "@-moz-anything {}"; + final CascadingStyleSheet aCSS = CSSReader.readFromString (sCSS, ECSSVersion.LATEST); + assertNotNull (aCSS); + assertEquals (2, aCSS.getRuleCount ()); + assertEquals (1, aCSS.getMediaRuleCount ()); + assertEquals (1, aCSS.getUnknownRuleCount ()); + + final CSSMediaRule aMR = aCSS.getMediaRuleAtIndex (0); + assertNotNull (aMR); + + assertEquals (1, aMR.getRuleCount ()); + assertEquals (1, aMR.getUnknownRuleCount ()); + } +}