Permalink
Browse files

Handle empty media types/queries in the parse_media method, not in @i…

  • Loading branch information...
1 parent 1ab4a85 commit 2793e725ea6d4b17a2f93d376462ddcabdc954eb @SimonSapin SimonSapin committed Jun 13, 2012
Showing with 4 additions and 6 deletions.
  1. +4 −6 tinycss/css21.py
View
@@ -554,11 +554,7 @@ def parse_at_rule(self, rule, previous_rules, errors, context):
'expected URI or STRING for @import rule, got '
+ head[0].type)
uri = head[0].value
- media_tokens = strip_whitespace(head[1:])
- if media_tokens:
- media = self.parse_media(media_tokens)
- else:
- media = ['all']
+ media = self.parse_media(strip_whitespace(head[1:]))
if rule.body is not None:
# The position of the ';' token would be best, but we don’t
# have it anymore here.
@@ -578,12 +574,14 @@ def parse_media(self, tokens):
Media Queries are expected to override this.
:param tokens:
- A non-empty list of tokens
+ A list of tokens
:raises:
:class:`~.parsing.ParseError` on invalid media types/queries
:returns:
For CSS 2.1, a list of media types as strings
"""
+ if not tokens:
+ return ['all']
media_types = []
for part in split_on_comma(remove_whitespace(tokens)):
types = [token.type for token in part]

0 comments on commit 2793e72

Please sign in to comment.