Skip to content

Commit 4052d12

Browse files
feat: supports :is, :where and :any pseudo-classes
2 parents b903b12 + cac8248 commit 4052d12

File tree

2 files changed

+101
-2
lines changed

2 files changed

+101
-2
lines changed

lib/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function getSelectors() {
178178
selectors[uniRegexp.typeMatchClass] = typeMatch("class");
179179
selectors[uniRegexp.typeMatchId] = typeMatch("id");
180180
var selectorsSecondHalf = {
181-
":(not|matches|has|local|global)\\((\\s*)": nestedPseudoClassStartMatch,
181+
":(not|any|-\\w+?-any|matches|is|where|has|local|global)\\((\\s*)": nestedPseudoClassStartMatch,
182182
":((?:\\\\.|[A-Za-z_\\-0-9])+)\\(": pseudoClassStartMatch,
183183
":((?:\\\\.|[A-Za-z_\\-0-9])+)": typeMatch("pseudo-class"),
184184
"::((?:\\\\.|[A-Za-z_\\-0-9])+)": typeMatch("pseudo-element"),

test/test-cases.js

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,106 @@ module.exports = {
361361
] }
362362
])
363363
],
364-
364+
"nested pseudo class with multiple selectors (:is)": [
365+
":is( h1, h2 )",
366+
singleSelector([{
367+
type: "nested-pseudo-class",
368+
name: "is",
369+
nodes: [{
370+
type: "selector",
371+
nodes: [{
372+
type: "element",
373+
name: "h1"
374+
}],
375+
before: " ",
376+
},
377+
{
378+
type: "selector",
379+
nodes: [{
380+
type: "element",
381+
name: "h2"
382+
}],
383+
before: " ",
384+
after: " ",
385+
},
386+
],
387+
}, ]),
388+
],
389+
"nested pseudo class with multiple selectors (:where)": [
390+
":where( h1, h2 )",
391+
singleSelector([{
392+
type: "nested-pseudo-class",
393+
name: "where",
394+
nodes: [{
395+
type: "selector",
396+
nodes: [{
397+
type: "element",
398+
name: "h1"
399+
}],
400+
before: " ",
401+
},
402+
{
403+
type: "selector",
404+
nodes: [{
405+
type: "element",
406+
name: "h2"
407+
}],
408+
before: " ",
409+
after: " ",
410+
},
411+
],
412+
}, ]),
413+
],
414+
"nested pseudo class with multiple selectors (:any)": [
415+
":any( h1, h2 )",
416+
singleSelector([{
417+
type: "nested-pseudo-class",
418+
name: "any",
419+
nodes: [{
420+
type: "selector",
421+
nodes: [{
422+
type: "element",
423+
name: "h1"
424+
}],
425+
before: " ",
426+
},
427+
{
428+
type: "selector",
429+
nodes: [{
430+
type: "element",
431+
name: "h2"
432+
}],
433+
before: " ",
434+
after: " ",
435+
},
436+
],
437+
}, ]),
438+
],
439+
"nested pseudo class with multiple selectors (:-vendor-any)": [
440+
":-vendor-any( h1, h2 )",
441+
singleSelector([{
442+
type: "nested-pseudo-class",
443+
name: "-vendor-any",
444+
nodes: [{
445+
type: "selector",
446+
nodes: [{
447+
type: "element",
448+
name: "h1"
449+
}],
450+
before: " ",
451+
},
452+
{
453+
type: "selector",
454+
nodes: [{
455+
type: "element",
456+
name: "h2"
457+
}],
458+
before: " ",
459+
after: " ",
460+
},
461+
],
462+
}, ]),
463+
],
365464
"available nested pseudo classes": [
366465
":not(:active):matches(:focus)",
367466
singleSelector([

0 commit comments

Comments
 (0)