diff --git a/src/index.js b/src/index.js index 645dfb4..d43142b 100644 --- a/src/index.js +++ b/src/index.js @@ -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) diff --git a/test/index.js b/test/index.js index ce0c605..682d5fa 100644 --- a/test/index.js +++ b/test/index.js @@ -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) {}", @@ -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(