Allow @font-face rules nested inside @media rules#68
Open
bysiber wants to merge 1 commit intojaraco:mainfrom
Open
Allow @font-face rules nested inside @media rules#68bysiber wants to merge 1 commit intojaraco:mainfrom
bysiber wants to merge 1 commit intojaraco:mainfrom
Conversation
Per MDN's At-Rules Nesting documentation, @font-face is allowed inside conditional at-rules like @media. However, cssutils was rejecting them with "This rule is not allowed in CSSMediaRule". This moves @font-face from the disallowed rules list to the factories dict in the CSS text parser, and removes CSSFontFaceRule from the rejected types in insertRule(). Fixes jaraco#30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As reported in #30,
@font-facerules nested inside@mediablocks are incorrectly rejected with:Per MDN's At-Rules documentation,
@font-faceis valid inside conditional at-rules like@media. This is also common in real-world CSS, e.g. Google Fonts serves@font-facewrapped in@media screen.The issue was in two places in
cssmediarule.py:The CSS text parser's
atrulehandler had@font-facein the disallowed list instead of the factories dict. Moved it to factories so it gets parsed as aCSSFontFaceRule.insertRule()was rejectingCSSFontFaceRuleinstances. Removed that check so font-face rules can be inserted programmatically too.Added a test covering both the parsing path and the
insertRule()path. All existing tests continue to pass.