Skip to content

Commit f89dfc6

Browse files
committed
Pass restrictions to arguments of any functional pseudo-class
The specification wants all logical pseudo-classes to pass restrictions at their position to their arguments. This commit extends this requirement to any functional pseudo-class. In fact, this already applied when they were compounded to a pseudo-element and they took a complex selector or a pseudo-class that cannot be compounded to this pseudo-element. w3c/csswg-drafts#12718
1 parent 3cf56b8 commit f89dfc6

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

__tests__/value.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4409,6 +4409,10 @@ describe('<selector-list>', () => {
44094409
':host(:not(:has(type)))',
44104410
':host-context(:not(type > type))',
44114411
':host-context(:not(:has(type)))',
4412+
'::part(name):current(:only-child)',
4413+
'::part(name):current(type)',
4414+
'::part(name):not(:current(:only-child))',
4415+
'::part(name):not(:current(type))',
44124416
'::slotted(:not(type > type))',
44134417
'::slotted(:not(:has(type)))',
44144418
// Invalid sub-pseudo-element

lib/parse/preprocess.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,21 @@ function preParseComplexSelectorUnit(node) {
191191
* when the combinator is omitted and there is no interleaving whitespace.
192192
*
193193
* It aborts parsing when the next token is not a pseudo whereas the context is
194-
* a logical pseudo-class compounded to a pseudo-element.
194+
* a functional pseudo-class compounded to a pseudo-element.
195195
*/
196196
function preParseCompoundSelector(node) {
197197
if (hasInvalidSiblingCombinator(node)) {
198198
return null
199199
}
200200
if (
201201
!node.input.peek(isColon)
202-
&& findFunction(node, node =>
203-
pseudos.logical[node.definition.name]
204-
&& findParent(
205-
node,
206-
node => node.parent?.definition.name === '<pseudo-compound-selector>',
207-
node => node.definition.name === '<subclass-selector>'))
202+
&& findFunction(node, node => {
203+
const compound = findParent(node, node => node.parent?.definition.name === '<pseudo-compound-selector>')
204+
if (compound) {
205+
return 0 < compound.children.length
206+
}
207+
return false
208+
})
208209
) {
209210
return error(node)
210211
}

0 commit comments

Comments
 (0)