Skip to content

Commit 83e8300

Browse files
authored
Merge pull request #5 from toddself/master
Prevent pseudo selector args from prefixing
2 parents 0d61a4b + 5dcd56a commit 83e8300

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ function postcssPrefix (prefix, options) {
2222
// if parent is not selector and
2323
selector.parent.type !== 'selector' ||
2424
// if not first node in container
25-
selector.parent.nodes[0] !== selector
25+
selector.parent.nodes[0] !== selector ||
26+
// don't prefix pseudo selector args unless it's `:not`
27+
(selector.parent.parent.type === 'pseudo' && selector.parent.parent.value !== ':not')
2628
) return
2729

2830
const prefixNode = getPrefixNode(prefix)

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
},
88
"devDependencies": {
99
"tape": "^4.2.1"
10+
},
11+
"scripts": {
12+
"test": "tape test/index.js"
1013
}
1114
}

test/fixture-out.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@
2323
@media screen and (max-width: 42rem) {
2424
#hello-world #another .thing > x-here {}
2525
}
26+
27+
#hello-world .stuff:nth-child(even) {}
28+
29+
#hello-world .stuff:nth-last-child(even) {}
30+
31+
#hello-world .stuff:nth-of-type(2) {}
32+
33+
#hello-world .stuff:nth-last-of-type(2) {}
34+
35+
#hello-world .stuff:not(#hello-world p) {}

test/fixture.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@ h2#thing {}
2323
@media screen and (max-width: 42rem) {
2424
#another .thing > x-here {}
2525
}
26+
27+
.stuff:nth-child(even) {}
28+
29+
.stuff:nth-last-child(even) {}
30+
31+
.stuff:nth-of-type(2) {}
32+
33+
.stuff:nth-last-of-type(2) {}
34+
35+
.stuff:not(p) {}

0 commit comments

Comments
 (0)