Skip to content

Commit 3cf56b8

Browse files
committed
Pseudo-elements cannot be qualified by a complex selector
A logical pseudo-class passes any restriction at its position to its arguments, which are restricted to pseudos when the logical pseudo-class is compounded to a pseudo-element. The implementation checked that these arguments were pseudos allowed to be compounded to this pseudo-element, but not whether they were combined.
1 parent 14eac43 commit 3cf56b8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

__tests__/value.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4388,7 +4388,7 @@ describe('<selector-list>', () => {
43884388
'::before:not(:only-child)',
43894389
'::before:not(:not(:only-child))',
43904390
'::before:not(type)',
4391-
'::before:not(:hover > type)',
4391+
'::before:not(:hover > :hover)',
43924392
'::part(name):only-child',
43934393
'::part(name):empty',
43944394
'::part(name):nth-child(1)',
@@ -4400,6 +4400,7 @@ describe('<selector-list>', () => {
44004400
'::part(name):not(type)',
44014401
'::part(name):has(:hover)',
44024402
'::part(name):not(:has(:hover))',
4403+
'::part(name):not(:hover > :hover)',
44034404
// Invalid functional pseudo argument
44044405
':has(:not(:has(type)))',
44054406
':current(:not(type > type))',

lib/parse/preprocess.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ function preParseCalcValue(node) {
7373
* selectors.
7474
*
7575
* It aborts parsing when the input is at the back of a pseudo-element with no
76-
* internal structure but is still not at the end of the selector.
76+
* internal structure, or in a functional pseudo compounded to it, but is still
77+
* not at the end of the selector. It only aborts parsing the combinator if it
78+
* is at the end of the selector.
7779
*
7880
* It aborts parsing when the grammar wants a relative selector but the context
7981
* only allows a compound selector.
@@ -85,14 +87,15 @@ function preParseCombinator(node) {
8587
const pseudoElement = findSibling(
8688
node,
8789
node => node.definition.name === '<pseudo-element-selector>',
88-
({ definition: { name } }) => name === '<subclass-selector>' || name?.startsWith('<relative'))
90+
({ definition: { name } }) => name === '<subclass-selector>' || name?.startsWith('<relative'),
91+
true)
8992
if (pseudoElement) {
9093
const { value: [, [, { name, types, value }]] } = pseudoElement
9194
const definition = types[0] === '<function>'
9295
? pseudos.elements.functions[name]
9396
: pseudos.elements.identifiers[value]
9497
if (!definition?.structured) {
95-
return error(node)
98+
return isComma(node.input.next()) ? null : error(node)
9699
}
97100
}
98101
const { context: { trees } } = node

0 commit comments

Comments
 (0)