Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Always match @ rules
if rule.at_keyword is not None:
return rule
# Clean selectors
cleaned_token_list = []
for token_list in split_on_comma(rule.selector):
# If the token list matches the tree
if self._token_list_matches_tree(token_list):
# Add a Comma if multiple token lists matched
if len(cleaned_token_list) > 0:
cleaned_token_list.append(
cssselect.parser.Token('DELIM', ',', len(cleaned_token_list) + 1))
# Append it to the list of cleaned token list
cleaned_token_list += token_list
# Return None if selectors list is empty
if not cleaned_token_list:
return None
# Update rule token list
rule.selector = cleaned_token_list
# Return cleaned rule
return rule