Skip to content

Commit 11e634c

Browse files
authored
[BUGFIX] Allow comma in selectors (#1293)
Also add a note that the specificity is incorrectly calculated in such cases. This will be addressed with a separate fix.
1 parent ec1f6dd commit 11e634c

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Please also have a look at our
110110

111111
### Fixed
112112

113+
- Allow comma in selectors (e.g. `:not(html, body)`) (#1293)
113114
- Insert `Rule` before sibling even with different property name
114115
(in `RuleSet::addRule()`) (#1270)
115116
- Ensure `RuleSet::addRule()` sets non-negative column number when sibling

src/Property/Selector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class Selector implements Renderable
2424
public const SELECTOR_VALIDATION_RX = '/
2525
^(
2626
(?:
27-
[a-zA-Z0-9\\x{00A0}-\\x{FFFF}_^$|*="\'~\\[\\]()\\-\\s\\.:#+>]* # any sequence of valid unescaped characters
28-
(?:\\\\.)? # a single escaped character
29-
(?:([\'"]).*?(?<!\\\\)\\2)? # a quoted text like [id="example"]
27+
[a-zA-Z0-9\\x{00A0}-\\x{FFFF}_^$|*="\'~\\[\\]()\\-\\s\\.:#+>,]* # any sequence of valid unescaped characters
28+
(?:\\\\.)? # a single escaped character
29+
(?:([\'"]).*?(?<!\\\\)\\2)? # a quoted text like [id="example"]
3030
)*
3131
)$
3232
/ux';

tests/Unit/Property/SelectorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public static function provideSelectorsAndSpecificities(): array
6060
'class with pseudo-selector' => ['.help:hover', 20],
6161
'ID' => ['#file', 100],
6262
'ID and descendant class' => ['#test .help', 110],
63+
'`not`' => [':not(#your-mug)', 100],
64+
// TODO, broken: The specificity should be the highest of the `:not` arguments, not the sum.
65+
'`not` with multiple arguments' => [':not(#your-mug, .their-mug)', 110],
6366
];
6467
}
6568

0 commit comments

Comments
 (0)