From 035e092b50d130367839fdcc0b1958f270f185f2 Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Sat, 28 Jun 2025 17:48:07 +0100 Subject: [PATCH] [BUGFIX] Allow comma in selectors Also add a note that the specificity is incorrectly calculated in such cases. This will be addressed with a separate fix. --- CHANGELOG.md | 1 + src/Property/Selector.php | 6 +++--- tests/Unit/Property/SelectorTest.php | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74a577d0..912d5dba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -110,6 +110,7 @@ Please also have a look at our ### Fixed +- Allow comma in selectors (e.g. `:not(html, body)`) (#1293) - Insert `Rule` before sibling even with different property name (in `RuleSet::addRule()`) (#1270) - Ensure `RuleSet::addRule()` sets non-negative column number when sibling diff --git a/src/Property/Selector.php b/src/Property/Selector.php index 180ffeba..daeed850 100644 --- a/src/Property/Selector.php +++ b/src/Property/Selector.php @@ -24,9 +24,9 @@ class Selector implements Renderable public const SELECTOR_VALIDATION_RX = '/ ^( (?: - [a-zA-Z0-9\\x{00A0}-\\x{FFFF}_^$|*="\'~\\[\\]()\\-\\s\\.:#+>]* # any sequence of valid unescaped characters - (?:\\\\.)? # a single escaped character - (?:([\'"]).*?(?,]* # any sequence of valid unescaped characters + (?:\\\\.)? # a single escaped character + (?:([\'"]).*?(? ['.help:hover', 20], 'ID' => ['#file', 100], 'ID and descendant class' => ['#test .help', 110], + '`not`' => [':not(#your-mug)', 100], + // TODO, broken: The specificity should be the highest of the `:not` arguments, not the sum. + '`not` with multiple arguments' => [':not(#your-mug, .their-mug)', 110], ]; }