Skip to content

Commit

Permalink
fix: ignore subselectors
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Mar 5, 2017
1 parent ed966de commit 02d2074
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/parser/gonzales.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ const gonzales = require('gonzales-pe')
class GonzalesParser {
static getSelectorTokensInRuleset(parsed) {
const selectors = []
parsed.traverseByType('selector', node => {
parsed.traverseByType('selector', (node, index, parent) => {
// don't target on subselectors like :not([disabled])
if (parent.type === 'arguments') {
return
}

const tokens = GonzalesParser.getTokensInSelector(node)
selectors.push({node, tokens})
})
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ html .something > foobar[something=x] #xb {
.unused, .something {
color: white;
}

madeup:not([role]) {
color: white;
}
1 change: 1 addition & 0 deletions test/nuke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('nuke.js', () => {
expect(result).to.not.contain('foobar[something=x]')
expect(result).to.not.contain('.something3')
expect(result).to.not.contain('.foo-bar-3')
expect(result).to.not.contain('madeup:not')
})

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

0 comments on commit 02d2074

Please sign in to comment.