Skip to content

Commit ee6f579

Browse files
michgeekromainmenke
michgeek
authored andcommitted
Add edge case about attribute selectors containing :not
1 parent 277bfeb commit ee6f579

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

plugins/postcss-selector-not/src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ function explodeSelector(pseudoClass, selector) {
88
if (selector && position > -1) {
99
const pre = selector.slice(0, position)
1010
const matches = balancedMatch("(", ")", selector.slice(position))
11+
12+
if (!matches) {
13+
return selector
14+
}
15+
1116
const bodySelectors = matches.body
1217
? list
1318
.comma(matches.body)

plugins/postcss-selector-not/test/index.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@ tape("postcss-selector-not", t => {
2020
"should really do nothing if there is no :not"
2121
)
2222

23+
t.equal(
24+
transform("em[attr=:not] {}"),
25+
"em[attr=:not] {}",
26+
"should do nothing if an attribute selector value contains :not"
27+
)
28+
29+
t.equal(
30+
transform("em[attr~=:not] {}"),
31+
"em[attr~=:not] {}",
32+
"should really do nothing if an attribute selector value contains :not"
33+
)
34+
35+
t.equal(
36+
transform("em[:not=abc] {}"),
37+
"em[:not=abc] {}",
38+
"should do nothing if a selector on an attribute named :not"
39+
)
40+
41+
t.equal(
42+
transform(":not {}"),
43+
":not {}",
44+
"should do nothing if :not has missing parenthesis"
45+
)
46+
2347
t.equal(
2448
transform(":not(a, b) {}"),
2549
":not(a):not(b) {}",
@@ -29,7 +53,7 @@ tape("postcss-selector-not", t => {
2953
t.equal(
3054
transform("tag:not(.class, .class2) {}"),
3155
"tag:not(.class):not(.class2) {}",
32-
"should transform directes :not()"
56+
"should transform into multiple :not()"
3357
)
3458

3559
t.equal(

0 commit comments

Comments
 (0)