-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix-qualified-rule-prelude-selector-parsing' into dev
- Loading branch information
Showing
1 changed file
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
"""Parsing of CSS text aligned with [CSS] specification(s).""" | ||
|
||
def _enable_selector_parsing(): | ||
def _enable_selector_parsing() -> None: | ||
"""Augment parsing procedures to enable parsing of CSS selectors. | ||
This adds on-demand parsing of the prelude part of every qualified rule (see the `prelude` attribute on `QualifiedRule`), when the `selector_list` property is accessed on the latter. Because parsing is only done when the property added with this procedure, is accessed, `csspring.syntax` remains compliant with its respective specification. | ||
""" | ||
from .syntax.parsing import normalize_input, QualifiedRule | ||
from .syntax.parsing import normalize_input, Product, QualifiedRule, tokens | ||
from .selectors import parse_selector_list | ||
def qualified_rule_selector_list(self): | ||
return parse_selector_list(normalize_input(self.prelude)) | ||
def qualified_rule_selector_list(self: QualifiedRule) -> Product | None: | ||
return parse_selector_list(normalize_input(tokens(self.prelude))) | ||
setattr(QualifiedRule, "selector_list", property(qualified_rule_selector_list)) | ||
|
||
_enable_selector_parsing() |