Skip to content
This repository has been archived by the owner on Jun 6, 2022. It is now read-only.

Commit

Permalink
Add edge case about attribute selectors containing :not
Browse files Browse the repository at this point in the history
  • Loading branch information
michgeek committed Dec 18, 2020
1 parent 64b10ed commit 8228db1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ function explodeSelector(pseudoClass, selector) {
if (selector && position > -1) {
const pre = selector.slice(0, position)
const matches = balancedMatch("(", ")", selector.slice(position))

if (!matches) {
return selector
}

const bodySelectors = matches.body
? list
.comma(matches.body)
Expand Down
26 changes: 25 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ tape("postcss-selector-not", t => {
"should really do nothing if there is no :not"
)

t.equal(
transform("em[attr=:not] {}"),
"em[attr=:not] {}",
"should do nothing if an attribute selector value contains :not"
)

t.equal(
transform("em[attr~=:not] {}"),
"em[attr~=:not] {}",
"should really do nothing if an attribute selector value contains :not"
)

t.equal(
transform("em[:not=abc] {}"),
"em[:not=abc] {}",
"should do nothing if a selector on an attribute named :not"
)

t.equal(
transform(":not {}"),
":not {}",
"should do nothing if :not has missing parenthesis"
)

t.equal(
transform(":not(a, b) {}"),
":not(a):not(b) {}",
Expand All @@ -29,7 +53,7 @@ tape("postcss-selector-not", t => {
t.equal(
transform("tag:not(.class, .class2) {}"),
"tag:not(.class):not(.class2) {}",
"should transform directes :not()"
"should transform into multiple :not()"
)

t.equal(
Expand Down

0 comments on commit 8228db1

Please sign in to comment.