Skip to content

Commit 02d2074

Browse files
committed
fix: ignore subselectors
1 parent ed966de commit 02d2074

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lib/parser/gonzales.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ const gonzales = require('gonzales-pe')
44
class GonzalesParser {
55
static getSelectorTokensInRuleset(parsed) {
66
const selectors = []
7-
parsed.traverseByType('selector', node => {
7+
parsed.traverseByType('selector', (node, index, parent) => {
8+
// don't target on subselectors like :not([disabled])
9+
if (parent.type === 'arguments') {
10+
return
11+
}
12+
813
const tokens = GonzalesParser.getTokensInSelector(node)
914
selectors.push({node, tokens})
1015
})

test/fixtures/content.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ html .something > foobar[something=x] #xb {
2525
.unused, .something {
2626
color: white;
2727
}
28+
29+
madeup:not([role]) {
30+
color: white;
31+
}

test/nuke.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('nuke.js', () => {
1919
expect(result).to.not.contain('foobar[something=x]')
2020
expect(result).to.not.contain('.something3')
2121
expect(result).to.not.contain('.foo-bar-3')
22+
expect(result).to.not.contain('madeup:not')
2223
})
2324

2425
it('should remove empty media sets', () => {

0 commit comments

Comments
 (0)