Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/conftest.cpython-314-pytest-9.0.2.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions commit_msg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Allow @font-face rules nested inside @media rules

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 #30
Binary file added cssutils/__pycache__/__init__.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/_fetch.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/_fetchgae.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/codec.cpython-314.pyc
Binary file not shown.
Binary file not shown.
Binary file added cssutils/__pycache__/errorhandler.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/helper.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/parse.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/prodparser.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/profiles.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/script.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/serialize.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/settings.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/tokenize2.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/__pycache__/util.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/css/__pycache__/__init__.cpython-314.pyc
Binary file not shown.
Binary file added cssutils/css/__pycache__/colors.cpython-314.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added cssutils/css/__pycache__/cssrule.cpython-314.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added cssutils/css/__pycache__/property.cpython-314.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added cssutils/css/__pycache__/value.cpython-314.pyc
Binary file not shown.
3 changes: 1 addition & 2 deletions cssutils/css/cssmediarule.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ def atrule(expected, seq, token, tokenizer):
factories = {
'@page': cssutils.css.CSSPageRule,
'@media': CSSMediaRule,
'@font-face': cssutils.css.CSSFontFaceRule,
}
if atval in (
'@charset ',
'@font-face',
'@import',
'@namespace',
'@variables',
Expand Down Expand Up @@ -320,7 +320,6 @@ def insertRule(self, rule, index=None):
# check hierarchy
if (
isinstance(rule, cssutils.css.CSSCharsetRule)
or isinstance(rule, cssutils.css.CSSFontFaceRule)
or isinstance(rule, cssutils.css.CSSImportRule)
or isinstance(rule, cssutils.css.CSSNamespaceRule)
or isinstance(rule, cssutils.css.MarginRule)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added cssutils/tests/__pycache__/__init__.cpython-314.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 18 additions & 0 deletions cssutils/tests/test_cssmediarule.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,24 @@ def test_incomplete(self):
}
self.do_equal_p(tests) # parse

def test_fontface_in_media_rule(self):
"CSSMediaRule with nested @font-face (issue #30)"
css = '@media screen { @font-face { font-family: x } }'
sheet = cssutils.parseString(css)
rule = sheet.cssRules[0]
assert isinstance(rule, cssutils.css.CSSMediaRule)
assert len(rule.cssRules) == 1
assert isinstance(rule.cssRules[0], cssutils.css.CSSFontFaceRule)
assert rule.cssRules[0].style.getPropertyValue('font-family') == 'x'

# also test insertRule programmatically
r = cssutils.css.CSSMediaRule()
fontface = cssutils.css.CSSFontFaceRule()
fontface.style.setProperty('font-family', 'test')
r.insertRule(fontface)
assert len(r.cssRules) == 1
assert isinstance(r.cssRules[0], cssutils.css.CSSFontFaceRule)

def test_reprANDstr(self):
"CSSMediaRule.__repr__(), .__str__()"
mediaText = 'tv, print'
Expand Down
Binary file added encutils/__pycache__/__init__.cpython-314.pyc
Binary file not shown.