diff --git a/src/Property/Selector.php b/src/Property/Selector.php index e5a8c9de..dcecf387 100644 --- a/src/Property/Selector.php +++ b/src/Property/Selector.php @@ -9,6 +9,7 @@ use Sabberworm\CSS\Parsing\ParserState; use Sabberworm\CSS\Parsing\UnexpectedTokenException; use Sabberworm\CSS\Property\Selector\Combinator; +use Sabberworm\CSS\Property\Selector\Component; use Sabberworm\CSS\Property\Selector\CompoundSelector; use Sabberworm\CSS\Property\Selector\SpecificityCalculator; use Sabberworm\CSS\Renderable; @@ -76,11 +77,11 @@ final public function __construct(string $selector) /** * @param list $comments * - * @throws UnexpectedTokenException + * @return list * - * @internal + * @throws UnexpectedTokenException */ - public static function parse(ParserState $parserState, array &$comments = []): self + private static function parseComponents(ParserState $parserState, array &$comments = []): array { // Whitespace is a descendent combinator, not allowed around a compound selector. // (It is allowed within, e.g. as part of a string or within a function like `:not()`.) @@ -109,6 +110,20 @@ public static function parse(ParserState $parserState, array &$comments = []): s } } + return $selectorParts; + } + + /** + * @param list $comments + * + * @throws UnexpectedTokenException + * + * @internal + */ + public static function parse(ParserState $parserState, array &$comments = []): self + { + $selectorParts = self::parseComponents($parserState, $comments); + // Check that the selector has been fully parsed: if (!\in_array($parserState->peek(), ['{', '}', ',', ''], true)) { throw new UnexpectedTokenException(