Skip to content

Commit 113b7de

Browse files
committed
feat: parse :is and :where as nested-pseudo-classes
1 parent b903b12 commit 113b7de

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-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|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: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,50 @@ module.exports = {
361361
] }
362362
])
363363
],
364-
364+
"nested pseudo class with multiple selectors (:is)": [
365+
":is( h1, h2 )",
366+
singleSelector([
367+
{
368+
type: "nested-pseudo-class",
369+
name: "is",
370+
nodes: [
371+
{
372+
type: "selector",
373+
nodes: [{ type: "element", name: "h1" }],
374+
before: " ",
375+
},
376+
{
377+
type: "selector",
378+
nodes: [{ type: "element", name: "h2" }],
379+
before: " ",
380+
after: " ",
381+
},
382+
],
383+
},
384+
]),
385+
],
386+
"nested pseudo class with multiple selectors (:where)": [
387+
":where( h1, h2 )",
388+
singleSelector([
389+
{
390+
type: "nested-pseudo-class",
391+
name: "where",
392+
nodes: [
393+
{
394+
type: "selector",
395+
nodes: [{ type: "element", name: "h1" }],
396+
before: " ",
397+
},
398+
{
399+
type: "selector",
400+
nodes: [{ type: "element", name: "h2" }],
401+
before: " ",
402+
after: " ",
403+
},
404+
],
405+
},
406+
]),
407+
],
365408
"available nested pseudo classes": [
366409
":not(:active):matches(:focus)",
367410
singleSelector([

0 commit comments

Comments
 (0)