Skip to content

Commit

Permalink
Merge branch 'fix-qualified-rule-prelude-selector-parsing' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
amn committed Sep 30, 2024
2 parents 5e0e193 + 889e7ba commit fde1a78
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/csspring/__init__.py
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()

0 comments on commit fde1a78

Please sign in to comment.